|
-
Jun 13th, 2004, 05:52 PM
#1
Thread Starter
Frenzied Member
why this update statement doesnt work
hi all, please check this code vb.net
VB Code:
Dim contact As Byte = CByte(radioyes.Checked)
Dim db As New OleDb.OleDbConnection(dbstring), usercode As Long = Request.Cookies("usercode").Value
'executing several updates
db.Open()
Dim cmd As New OleDb.OleDbCommand("update [users] set users.birthdate = #" & txtbirthdate.Text & "# where users.serial = " & usercode.ToString, db)
Dim xx As Long
xx = cmd.ExecuteNonQuery()
Dim cmd2 As New OleDb.OleDbCommand("update [users] set users.mail = '" & txtemail.Text & "' where users.serial = " & usercode.ToString, db)
cmd2.ExecuteNonQuery()
Dim cmd3 As New OleDb.OleDbCommand("update [users] set users.contact = " & CByte(radioyes.Checked).ToString & " where users.serial = " & usercode.ToString, db)
cmd3.ExecuteNonQuery()
db.Close()
Response.Redirect("frmview.aspx")
this is supposed to update a user profile on an asp web page.
i have checked the usercode variable and it is working fine, but the database is not updated.
no errors are generated , but the data still the same
can anyone help me here ?????
thx in advance
-
Jun 14th, 2004, 01:21 AM
#2
Member
Hi,
1.
you are using 3 Updates for only one record?
Update -table- SET field1 = value1, fieldx = valuex WHERE XY = Z
2.
xx = cmd.ExecuteNonQuery()
Is this truly the correct sub?
3.
Maybe you should use ADO, if possible.
cu
-
Jun 14th, 2004, 06:26 PM
#3
Thread Starter
Frenzied Member
hi Jens_Radtke
about your points,
1 - the problem stays still even when i execute one update statement on the row instead of three
2 - this is not a query, so i think executenonquery is the right solution for (update,insert,delete statements)
3 - This is actually ADO.Net. so i dont see your point
-
Jun 14th, 2004, 07:41 PM
#4
Frenzied Member
Surround each occurence of "users" with brackets.
If you're calling ToString on some elements of the SQL, you'd need to surround those with single quotes as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|