jalo Posted August 24, 2005 Posted August 24, 2005 after reading some posts here, i even added the [] around the fields... but still the update does not update... pls help... updateCommand3 = New OleDb.OleDbCommand("UPDATE [Event_Nuclear] SET [Event_Nuclear].[Number_Of_Levels] = ? WHERE [Event_Nuclear].[sS_Event_Nuclear_ID] = ?", Me.connection) updateCommand3.Parameters.Add(New OleDb.OleDbParameter(Me.EventNuclID, OleDb.OleDbType.Integer)) updateCommand3.Parameters.Add(New OleDb.OleDbParameter("Number_Of_Levels", OleDb.OleDbType.Integer)) updateCommand3.Prepare() updateCommand3.Parameters.Item("Number_Of_Levels").Value() = Integer.Parse(Me.TextBox1.Text) updateCommand3.Parameters.Item(Me.EventNuclID).Value() = Me.eventID updateCommand3.ExecuteNonQuery() Quote
jalo Posted August 24, 2005 Author Posted August 24, 2005 (edited) if i replaced the first '?' with an integer - it works... but i still can't figure out what is wrong with the '?' version.. if i print the value of the parameter after retrieving it from the textbox - it is the right value.... Edited August 24, 2005 by jalo Quote
jalo Posted August 24, 2005 Author Posted August 24, 2005 oh... i figured it... i guess i cannot use '?' (i.e. a parameter) in the SET section of the query. so i re-wrote like below and it works now! :p [color=Red]Dim temp As Integer = Integer.Parse(Me.TextBox1.Text)[/color] updateCommand3 = New OleDb.OleDbCommand("UPDATE [Event_Nuclear] SET [color=Red][Event_Nuclear].[Number_Of_Levels] = '" & temp & "'[/color] WHERE [Event_Nuclear].[sS_Event_Nuclear_ID] = ?", Me.connection) updateCommand3.Parameters.Add(New OleDb.OleDbParameter(Me.EventNuclID, OleDb.OleDbType.Integer)) updateCommand3.Prepare() Quote
Administrators PlausiblyDamp Posted August 24, 2005 Administrators Posted August 24, 2005 You should be able to use a parameter to do this - I personally would always advise against using string concatenation to do DB stuff. If you swap the order you add the parameters in does that work? Also is there a reason you are using Me.EventNuclID as the name of the parameter in your code? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.