Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Command --- drives me crazy 1

Status
Not open for further replies.

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
 
what is the error message? this will tell you the problem.
if i had to guess I would say the problem is the value of telephone and what the db requires.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Dear jmeckley, thanx for your awnser....
There isn't any error message...just doesn't update.

The db requires text for telephone....

The mystery is that when I don't put the "telephone", the query works...
 
then you need to step through your code and make sure the values are what you think they are. if they are correct. then you need to test the sql statement in the database and make sure the sql is correct.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
This might be half ass but, I throw a label on my page and after I parse my SQL Command, I set that label to display the SQL command so I can see it on the fly with all the variables passed in it without having to go into debug view and step through the code to view my completed SQL statement. I do this just for cases like this. most of the time with me it is a simple misspelled word.
 
If you use Try ... Catch statements, then you would know what the error is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top