error for update query

jalo

Active member
Joined
Aug 9, 2005
Messages
28
this code for a parameterized update query is giving me an error that i cant figure out what the problem is. my code:

Code:
updateCommand1 = New OleDb.OleDbCommand("INSERT INTO Event_Nuclear (SS_Patient_ID, EventAge, Weight, Height, StudyType, EventDate,StudyNumber, PILocation, Indication) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Me.OleDbConnection1)

            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("PID", OleDb.OleDbType.Numeric, 10))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("EventAge", OleDb.OleDbType.Numeric, 3))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Weight", OleDb.OleDbType.Numeric, 3))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Height", OleDb.OleDbType.Numeric, 3))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyType", OleDb.OleDbType.VarChar, 40))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("RNADate", OleDb.OleDbType.Date))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyNo", OleDb.OleDbType.VarChar, 15))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Location", OleDb.OleDbType.VarChar, 30))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Indication", OleDb.OleDbType.Numeric))
            updateCommand1.Prepare()


the error:

Code:
System.InvalidOperationException: OleDbCommand.Prepare method requires parameters of type 131 have an explicitly set Precision and Scale.
   at System.Data.OleDb.OleDbParameter.Prepare(OleDbCommand cmd)
   at System.Data.OleDb.OleDbCommand.PrepareCommandText(Int32 expectedExecutionCount)
   at System.Data.OleDb.OleDbCommand.Prepare()

is my query wrong? any ideas?
 
are your Numerics really numerics, or can you get away with specifiying them as integers????

C#:
           updateCommand1.Parameters.Add(New OleDb.OleDbParameter("PID", OleDb.OleDbType.Integer))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("EventAge", OleDb.OleDbType.Integer))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Weight", OleDb.OleDbType.Integer))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Height", OleDb.OleDbType.Integer))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyType", OleDb.OleDbType.VarChar, 40))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("RNADate", OleDb.OleDbType.Date))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyNo", OleDb.OleDbType.VarChar, 15))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Location", OleDb.OleDbType.VarChar, 30))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Indication", OleDb.OleDbType.Integer))
            updateCommand1.Prepare()
should work. . .

else, you will have to specify precision/scale before preparing:

C#:
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("PID", OleDb.OleDbType.Numeric))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("EventAge", OleDb.OleDbType.Numeric))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Weight", OleDb.OleDbType.Numeric))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Height", OleDb.OleDbType.Numeric))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyType", OleDb.OleDbType.VarChar, 40))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("RNADate", OleDb.OleDbType.Date))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyNo", OleDb.OleDbType.VarChar, 15))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Location", OleDb.OleDbType.VarChar, 30))
            updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Indication", OleDb.OleDbType.Numeric))
 
// Specify Precision and size for numerics:
            updateCommand1.Parameters["PID"].Precision = {some precision};
            updateCommand1.Parameters["PID"].Scale = {some scale};
            updateCommand1.Parameters["EventAge"].Precision = {some precision};
            updateCommand1.Parameters["EventAge"].Scale = {some scale};
            updateCommand1.Parameters["Weight"].Precision = {some precision};
            updateCommand1.Parameters["Weight"].Scale = {some scale};
            updateCommand1.Parameters["Height"].Precision = {some precision};
            updateCommand1.Parameters["Height"].Scale = {some scale};
            updateCommand1.Parameters["Indication"].Precision = {some precision};
            updateCommand1.Parameters["Indication"].Scale = {some scale};
 
// now prepare
            updateCommand1.Prepare()
 
Back
Top