gi11ies
Programmer
- Mar 26, 2002
- 52
Hi, I have a web page with textboxes on it that are populated from calling the database in the Page_Load, and I want to be able to update the row in the database from changes to these values in the textboxes when I click the update button.
In my code it works fine if I hard code a value into the sql, ie (employee_first='John') but (employee_first='" + firstName.Text + ") will not work at all, it wont take the changes values in the text boxes and update the database with them.
The code I use for the update button is:
Private Sub btnUpdate ( ByVal sender as System.Object, ByVal e as EventArgs )
Dim ctEmpConn As OleDbConnection
Dim ctConn1 As String
ctConn1 = ConfigurationSettings.AppSettings("connString1")
ctEmpConn = New OleDbConnection(ctConn1)
ctEmpConn.Open
Dim ctEmpSQL as String = "update employees set employee_first='" + firstName.Text + "', employee_last='" + lastName.Text + "' where employee_id=1"
Dim ctEmpCmd as New OleDbCommand(ctEmpSQL, ctEmpConn)
ctEmpCmd.ExecuteNonQuery()
ctEmpConn.Close
End Sub
Any Help with this would be great.
Gillies
In my code it works fine if I hard code a value into the sql, ie (employee_first='John') but (employee_first='" + firstName.Text + ") will not work at all, it wont take the changes values in the text boxes and update the database with them.
The code I use for the update button is:
Private Sub btnUpdate ( ByVal sender as System.Object, ByVal e as EventArgs )
Dim ctEmpConn As OleDbConnection
Dim ctConn1 As String
ctConn1 = ConfigurationSettings.AppSettings("connString1")
ctEmpConn = New OleDbConnection(ctConn1)
ctEmpConn.Open
Dim ctEmpSQL as String = "update employees set employee_first='" + firstName.Text + "', employee_last='" + lastName.Text + "' where employee_id=1"
Dim ctEmpCmd as New OleDbCommand(ctEmpSQL, ctEmpConn)
ctEmpCmd.ExecuteNonQuery()
ctEmpConn.Close
End Sub
Any Help with this would be great.
Gillies