Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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()

Posted (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 by jalo
Posted

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()

  • Administrators
Posted

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?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...