Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code:
Dim sqlQRY As String = "UPDATE Students SET Company='" & companyTextBox.Text & "', last name='" & LastNameTextBox.Text & "', first name='" & FirstNameTextBox.Text & "', email address='" & emailaddressTextBox.Text & "' WHERE student id='" & StudentIDTextBox.Text & "'"
Try
conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand(sqlQRY, conn)
cmd.ExecuteNonQuery()
MsgBox("Record successfully saved...", MsgBoxStyle.Information)
Catch ex As OleDbException
MsgBox("Error: " & ex.ToString & vbCrLf)
Finally
conn.Close()
End Try
Posted

1 solution

Since your field names have spaces in them you need to put them in brackets. []

SQL
UPDATE Students SET [last name] = ...


However, there is a huge security problem with doing code this way. You need to add the value in as a parameterized query instead. I would suggest you read up on Sql Injections.
 
Share this answer
 

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