jalo Posted August 18, 2005 Posted August 18, 2005 this code for a parameterized update query is giving me an error that i can't figure out what the problem is. my 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: 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? Quote
Joe Mamma Posted August 18, 2005 Posted August 18, 2005 are your Numerics really numerics, or can you get away with specifiying them as integers???? 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: 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() Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
jalo Posted August 19, 2005 Author Posted August 19, 2005 yes - thank you. changing from Numeric to Integer solve the issue! :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.