Hey guys how is everyone doing today?.
As for me I'm doing pretty good , but I think I'm messing up in an update SQL statement when I try to pass
certain values into Access.
Well here is the scene
I have 2 text boxes. 1 of the textbox the User inserts their User ID and the second one contains the user Name
Now I know I can't update the USER ID because it is a Primary key in Access...but what I do want to update is the Name from that
particular User ID.
So in other words I want to be able to put the user ID and then update their attributes.
Here is a small example of the code.
Dim FirstName = txtFirstName.Text.Trim
Dim UserID = txtUserID.Text.Trim
Dim connString As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = X:\members.mdb;"
Dim myConnection As OleDbConnection = New OleDbConnection
Dim updateCmd As OleDbCommand = New OleDbCommand
myConnection.ConnectionString = connString
.Connection = myConnection
.CommandText = " Update [userTable] Set FirstName = @FirstName" & _ *////Im sure there is something wrong here?
" Where User_ID=@User_ID "
.CommandType = CommandType.Text
.Parameters.Add(New OleDbParameter("@User_ID", OleDbType.Char, 10))
.Parameters.Add(New OleDbParameter("@FirstName", OleDbType.Char, 25))
.Parameters("@User_ID").Value = UserID
.Parameters("@FirstName").Value = FirstName
Catch OleDbExceptionErr As OleDbException
Catch InvalidOperationExceptionErr As InvalidOperationException
'Cleaning up the Mess
updateCmd = Nothing
myConnection = Nothing
I may have maybe a syntax error in the SQL statement or maybe just the way I'm approaching the objective of this code.
Thankyou in advance guys :)