Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please kindly help me with this. and secondly i have like 30 forms in my project, whenever i launch the debug it takes a while before coming up, very slow. please help me out

What I have tried:

VB
Public Class Biochemistry

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim conn As New OleDb.OleDbConnection
        Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Buthdatabase.accdb;Persist Security Info=False"
        Dim cmd As New OleDb.OleDbCommand

        Try
            conn.ConnectionString = connStr
            conn.Open()
            cmd.Connection = conn

            cmd.CommandText = "INSERT INTO Biochemistry ([Hospital Number],[Path No (Lab Number)],[Patient's Name],[Other Names],[Age],[Sex],[Ethnic],[Clinician],[Ward/Dept],[Clinical Summary and Diagnosis],[Materials],[Specimen],[Type of Biochemistry],[Date of Request],[Signature Of Doctor],[Serum Bicarbonate],[Serum Chloride],[Serun Sodium],[Serum Potassium],[Serum Calcium],[Serum Phosphorus],[SGOT],[SGPT],[Serum Amylase],[Urinary Amylase],[Serum Lipase],[Urinary Lipase],[Alkaline Phosphatase],[Gamma GPT],[Serum Creatinine],[Serum Urea],[Urinary Creatinine],[Uric Acid],[Serum Cholesterol],[Serum VLDL],[Serum HDL],[Serum LDL],[Serum Triglyceride],[Serum Iron],[Random Blood Sugar],[Fasting Blood Sugar],[2 Hour Post Prandial],[Bilirubin Conjugated],[Unconjugated Bilirubin],[Total Bilirubin],[Serum thymol Turbidity],[Serum Thymol Floculation],[CSF Protein],[CSF Chloride],[CSF Sugar],[Serum Magnesium],[OTHER TESTS]) " & _
                         "VALUES ([@HospitalNumber],[@PathNo(LabNumber)],[@Patient'sName],[@Other'sName],[@Age],[@Sex],[@Ethnic],[@Clinician],[@Ward/Dept],[@ClinicalSummaryandDiagnosis],[@Materials],[@Specimen],[@TypeofBiochemistry],[@DateofRequest],[@SignatureOfDoctor],[@SerumBicarbonate],[@SerumChloride],[@SerunSodium],[@SerumPotassium],[@SerumCalcium],[@SerumPhosphorus],[@SGOT],[@SGPT],[@SerumAmylase],[@UrinaryAmylase],[@SerumLipase],[@UrinaryLipase],[@AlkalinePhosphatase],[@GammaGPT],[@SerumCreatinine],[@SerumUrea],[@UrinaryCreatinine],[@UricAcid],[@SerumCholesterol],[@SerumVLDL],[@SerumHDL],[@SerumLDL],[@SerumTriglyceride],[@SerumIron],[@RandomBloodSugar],[@FastingBloodSugar],[@2HourPostPrandial],[@BilirubinConjugated],[@UnconjugatedBilirubin],[@TotalBilirubin],[@SerumthymolTurbidity],[@SerumThymolFloculation],[@CSFProtein],[@CSFChloride],[@CSFSugar],[@SerumMagnesium],[@OTHERTESTS]); "

            cmd.Parameters.AddWithValue("@HospitalNumber", TextBox1.Text)
            cmd.Parameters.AddWithValue("@PathNo(LabNumber)", TextBox12.Text)
            cmd.Parameters.AddWithValue("@Patient'sName", TextBox2.Text)
            cmd.Parameters.AddWithValue("@Other'sName", TextBox3.Text)
            cmd.Parameters.AddWithValue("@Age", TextBox4.Text)
            cmd.Parameters.AddWithValue("@Sex", TextBox5.Text)
            cmd.Parameters.AddWithValue("[@Ethnic", TextBox6.Text)
            cmd.Parameters.AddWithValue("@Clinician", TextBox7.Text)
            cmd.Parameters.AddWithValue("@Ward/Dept", TextBox27.Text)
            cmd.Parameters.AddWithValue("@ClinicalSummaryandDiagnosis", TextBox8.Text)
            cmd.Parameters.AddWithValue("@Materials", TextBox10.Text)
            cmd.Parameters.AddWithValue("@Specimen", TextBox39.Text)
            cmd.Parameters.AddWithValue("@@TypeofBiochemistry", TextBox51.Text)
            cmd.Parameters.AddWithValue("@DateofRequest", DateTime.Text)
            cmd.Parameters.AddWithValue("@SignatureOfDoctor", TextBox11.Text)
            cmd.Parameters.AddWithValue("@SerumBicarbonate", TextBox21.Text)
            cmd.Parameters.AddWithValue("@SerumChloride", TextBox22.Text)
            cmd.Parameters.AddWithValue("@SerunSodium", TextBox20.Text)
            cmd.Parameters.AddWithValue("@@SerumPotassium", TextBox19.Text)
            cmd.Parameters.AddWithValue("@SerumCalcium", TextBox18.Text)
            cmd.Parameters.AddWithValue("@SerumPhosphorus", TextBox17.Text)
            cmd.Parameters.AddWithValue("@SGOT", TextBox16.Text)
            cmd.Parameters.AddWithValue("@SGPT", TextBox15.Text)
            cmd.Parameters.AddWithValue("@SerumAmylase", TextBox14.Text)
            cmd.Parameters.AddWithValue("@UrinaryAmylase", TextBox13.Text)
            cmd.Parameters.AddWithValue("@SerumLipase", TextBox9.Text)
            cmd.Parameters.AddWithValue("@UrinaryLipase", TextBox25.Text)
            cmd.Parameters.AddWithValue("@AlkalinePhosphatase", TextBox24.Text)
            cmd.Parameters.AddWithValue("@GammaGPT", TextBox29.Text)
            cmd.Parameters.AddWithValue("@SerumCreatinine", TextBox28.Text)
            cmd.Parameters.AddWithValue("@SerumUrea", TextBox30.Text)
            cmd.Parameters.AddWithValue("@UrinaryCreatinine", TextBox31.Text)
            cmd.Parameters.AddWithValue("@UricAcid", TextBox32.Text)
            cmd.Parameters.AddWithValue("@SerumCholesterol", TextBox33.Text)
            cmd.Parameters.AddWithValue("@SerumVLDL", TextBox34.Text)
            cmd.Parameters.AddWithValue("@SerumHDL", TextBox35.Text)
            cmd.Parameters.AddWithValue("@SerumLDL", TextBox36.Text)
            cmd.Parameters.AddWithValue("@SerumTriglyceride", TextBox37.Text)
            cmd.Parameters.AddWithValue("@SerumIron", TextBox38.Text)
            cmd.Parameters.AddWithValue("@RandomBloodSugar", TextBox26.Text)
            cmd.Parameters.AddWithValue("@FastingBloodSugar", TextBox41.Text)
            cmd.Parameters.AddWithValue("@2HourPostPrandial", TextBox40.Text)
            cmd.Parameters.AddWithValue("@BilirubinConjugated", TextBox42.Text)
            cmd.Parameters.AddWithValue("@UnconjugatedBilirubin", TextBox43.Text)
            cmd.Parameters.AddWithValue("@TotalBilirubin", TextBox44.Text)
            cmd.Parameters.AddWithValue("@SerumthymolTurbidity", TextBox45.Text)
            cmd.Parameters.AddWithValue("@SerumThymolFloculation", TextBox46.Text)
            cmd.Parameters.AddWithValue("@CSFProtein", TextBox47.Text)
            cmd.Parameters.AddWithValue("@CSFChloride", TextBox48.Text)
            cmd.Parameters.AddWithValue("@CSFSugar", TextBox49.Text)
            cmd.Parameters.AddWithValue("@SerumMagnesium", TextBox50.Text)
            cmd.Parameters.AddWithValue("@OTHERTESTS", TextBox23.Text)
           

            cmd.ExecuteNonQuery()
            conn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

End Class
Posted
Updated 7-Aug-17 4:59am
v2
Comments
Graeme_Grant 7-Aug-17 10:57am    
Please do not repost questions - originally asked here: Syntax error insert into statement[^]

The advice that you previously received is very sound advice that you need to listen to and follow. Please fix as recommended before asking again.
Member 13341316 7-Aug-17 11:00am    
but the errors i got earlier was different from this one
Michael_Davies 7-Aug-17 11:47am    
Typo?

cmd.Parameters.AddWithValue("[@Ethnic", TextBox6.Text)

and

cmd.Parameters.AddWithValue("@@TypeofBiochemistry", TextBox51.Text)

Also putting [] round a name means it is a field/variable name, not sure but to me the result of putting [] round the data values would produce just that literally [the actual data] whereas you just want just the data, again not sure of the result as never done it, it just looks so wrong.

Using ' in a field name, asking for trouble.

Looking at the other posting raised by Graeme you have not even tried with the help given, all of the above I've just mentioned is mentioned there, fix the issues and come back if it still fails.
Member 13341316 7-Aug-17 14:05pm    
thank you so much for your help. i really appreciate it

1 solution

There is a lot of information in your code to go through.

Firstly, choosing better control names will help you out later - what is "TextBox24"? I can tell it is a textbox, but not that it relates to alkaline phosphatase.


That notwithstanding, this sounds like there is a type mismatch with what you are passing and what is expected. Check your code: Are you passing in a string to where a number is expected?
 
Share this answer
 
Comments
Member 13341316 7-Aug-17 14:06pm    
thank you so much, but please what will i do to my project, i have like 30 forms in my project, whenever i launch the debug it takes a while before coming up, very slow.
Lockwood 9-Aug-17 8:45am    
You're not going to like this but the best thing to do with this project is to stop, take a deep breath and have a look at the whole thing from a distance.

As others have said, your data structure is not that great. Your object names are not that great either. Take the time now to refactor as much as you can and then look at the project again once you have completed that housekeeping.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900