[RESOLVED] can I use this to update the database?
Hello guys,
I know that this question have been asked thousand times but I really need some explanation here. I created a form, 2 buttons and textboxes.
The user can only view their info when the form load. i have added 2 buttons that enable user to edit the data but only certain data are allowed which are address, contact number and email. I wrote this code but nothing happen to the database.
I wanted to update email, address and contact number of a particular row.
I know something missing here but I'm not sure what is it.
OleDbConnection1.Open()
Dim mycmd AsNew OleDbCommand("UPDATE STUDENT SET Address = @Address, email = @email, contact_num = @contact_num WHERE Stud_ID = @Stud_ID", OleDbConnection1)
mycmd.Parameters.Add("@Address", txtaddress.Text)
mycmd.Parameters.Add("@email", txtemail.Text)
mycmd.Parameters.Add("@contact_num", txtcontact.Text)
Try
mycmd.ExecuteNonQuery()
Catch ex As Exception
EndTry
OleDbConnection1.Close()
Hello guys,
I know that this question have been asked thousand times but I really need some explanation here. I created a form, 2 buttons and textboxes.
The user can only view their info when the form load. i have added 2 buttons that enable user to edit the data but only certain data are allowed which are address, contact number and email. I wrote this code but nothing happen to the database.
I wanted to update email, address and contact number of a particular row.
I know something missing here but I'm not sure what is it.
OleDbConnection1.Open()
Dim mycmd AsNew OleDbCommand("UPDATE STUDENT SET Address = @Address, email = @email, contact_num = @contact_num WHERE Stud_ID = @Stud_ID", OleDbConnection1)
mycmd.Parameters.Add("@Address", txtaddress.Text)
mycmd.Parameters.Add("@email", txtemail.Text)
mycmd.Parameters.Add("@contact_num", txtcontact.Text)
Try
mycmd.ExecuteNonQuery()
Catch ex As Exception
EndTry
OleDbConnection1.Close()
Last edited: