Update_Customer not working

S

Sparky Arbuckle

My TRY CATCH shows Error when I run this. Can anyone see what's wrong
with this? Each textbox has OnTextChanged="ConChanged". This changed
boolean to TRUE and then Updates the customer.

Sub Update_Customer()

Dim strText as string

Dim strSQL as string = "UPDATE tblCustomers SET " & _
"(strEmail, strFName, strLName, strStreet, strCity, strState,
strZip) VALUES (" & _
"'" & tbEmail.text & "'," & _
"'" & tbFName.text & "'," & _
"'" & tbLName.text & "'," & _
"'" & tbStreet.text & "'," & _
"'" & tbCity.text & "'," & _
"'" & tbState.text & "'," & _
"'" & tbZip.text & "');"

'Dim strSQL as string = "UPDATE tblCustomers SET strEmail = '" &
tbEmail.text & "', strFName = '" & tbFName.text & "', " & _
' "strLName = '" & tbLName.text & "', strStreet =
'" & tbStreet.text & "', strCity = '" & tbCity.text & "', " & _
' "strState = '" & tbState.text & "', strZip = '"
& tbZip.text & "' WHERE CustID = " & ViewState("CustID") & ";"


TRY

Dim objConnection as New OLEDBConnection(myConnection)
Dim objCmd as New OLEDBCommand(strSQL, objConnection)
objCmd.Connection.Open()
objCmd.ExecuteNonQuery

Response.redirect("CheckOut.aspx?order=ASDF")
objCmd.Connection.Close()

Catch objError as Exception
Response.Write("Error")
END TRY

AddMe.Visible = FALSE
Success.Visible = TRUE


END Sub
 
S

Sparky Arbuckle

Even the strSQL that I have commented out doesn't work. I can't figure
this out for the life of me!
 
K

Ken Dopierala Jr.

Hi,

Could you set a break point on:

Response.Write("Error")

And then tell us what objError.Message says. From there we should be able
to figure this out. Good luck! Ken.
 
P

Patrick Olurotimi Ige

Sparky ,
Are you using VS.NET?
Break point is under the Menu "Debug" .
 
K

Ken Dopierala Jr.

Hi,

A breakpoint halts execution and let's you step through your code line by
line so you can check values. If you are using VS.Net you can just click to
the left of the Response.Write("Error") line and it will set a breakpoint.
Alternatively change:

Response.Write("Error")

To

Response.Write(objError.Message)

Then run your code. This will print out the error message you are receiving
and that error message should tell us pretty specifically why your code is
erroring out. Actually put the line below there instead and we should be
able to figure this out even faster:

Response.Write("Error Message: " + objError.Message + " - SQL: " +
strSQL)

This will now print out the error message and the SQL that you are using.
It should put it write in your browser when you run the app so you'll just
need to copy and paste it into your response. Good luck! Ken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top