eulogy6
Programmer
- Apr 30, 2004
- 26
Hi,
I have the following code:
The update works when I've not the telephone field...and when I put it...doesn't.
Do you have any idea?
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim mySql As String
Dim myCommand As OleDb.OleDbCommand
Dim LblUserID As String
Dim LblUsername As String
Dim LblPassword As String
Dim LblName As String
Dim LblEmail As String
Dim LblTel As String
LblEmail = CType(e.Item.FindControl("EmailU"), TextBox).Text
LblName = CType(e.Item.FindControl("NameU"), TextBox).Text
LblPassword = CType(e.Item.FindControl("PasswordU"), TextBox).Text
LblTel = CType(e.Item.FindControl("TelephoneU"), TextBox).Text
LblUserID = CType(e.Item.FindControl("UserIDU"), Label).Text
LblUsername = CType(e.Item.FindControl("UsernameU"), TextBox).Text
mySql = "UPDATE Users SET Email=@Email,Name=@Name,[Password]=@Password,Tel=@Telephone,Username=@Username WHERE (UserID = @ID) "
myCommand = New OleDb.OleDbCommand(mySql, Me.OleDbConnection1)
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Email", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Name", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Password", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Telephone", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@ID", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Username", SqlDbType.Char))
myCommand.Parameters("@Email").Value = LblEmail
myCommand.Parameters("@Name").Value = LblName
myCommand.Parameters("@Password").Value = LblPassword
myCommand.Parameters("@Telephone").Value = LblTel
myCommand.Parameters("@ID").Value = LblUserID
myCommand.Parameters("@Username").Value = LblUsername
OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("bin\users.mdb") & ""
OleDbConnection1.Open()
myCommand.ExecuteNonQuery()
OleDbConnection1.Close()
DataGrid1.EditItemIndex = -1
BindGridUsers()
End Sub
Thanx
I have the following code:
The update works when I've not the telephone field...and when I put it...doesn't.
Do you have any idea?
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim mySql As String
Dim myCommand As OleDb.OleDbCommand
Dim LblUserID As String
Dim LblUsername As String
Dim LblPassword As String
Dim LblName As String
Dim LblEmail As String
Dim LblTel As String
LblEmail = CType(e.Item.FindControl("EmailU"), TextBox).Text
LblName = CType(e.Item.FindControl("NameU"), TextBox).Text
LblPassword = CType(e.Item.FindControl("PasswordU"), TextBox).Text
LblTel = CType(e.Item.FindControl("TelephoneU"), TextBox).Text
LblUserID = CType(e.Item.FindControl("UserIDU"), Label).Text
LblUsername = CType(e.Item.FindControl("UsernameU"), TextBox).Text
mySql = "UPDATE Users SET Email=@Email,Name=@Name,[Password]=@Password,Tel=@Telephone,Username=@Username WHERE (UserID = @ID) "
myCommand = New OleDb.OleDbCommand(mySql, Me.OleDbConnection1)
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Email", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Name", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Password", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Telephone", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@ID", SqlDbType.Char))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@Username", SqlDbType.Char))
myCommand.Parameters("@Email").Value = LblEmail
myCommand.Parameters("@Name").Value = LblName
myCommand.Parameters("@Password").Value = LblPassword
myCommand.Parameters("@Telephone").Value = LblTel
myCommand.Parameters("@ID").Value = LblUserID
myCommand.Parameters("@Username").Value = LblUsername
OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("bin\users.mdb") & ""
OleDbConnection1.Open()
myCommand.ExecuteNonQuery()
OleDbConnection1.Close()
DataGrid1.EditItemIndex = -1
BindGridUsers()
End Sub
Thanx