Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 4.33 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-26-2005, 02:36 PM   PM User | #1
cbowen2
New to the CF scene

 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
cbowen2 is an unknown quantity at this point
Syntax error in UPDATE statement

The following code generates an error and I am not sure why. Anyone have any ideas?

cmdString2 = string.Format( "UPDATE USERS SET password='" & txtConfirmPassword.Text & "' WHERE username='" & dtrResults("username") & "'")

cmdUpdate = New OleDbCommand( cmdString2, conLogin2 )

conLogin2.Open()
cmdUpdate.ExecuteNonQuery()
conLogin2.Close()

When I display the update statement it looks like this:

UPDATE USERS SET password='pswrd' WHERE username='usrname'

I am pretty sure that is ok, but it errors out on the line cmdUpdate.ExecuteNonQuery()

Thank you for any advice.

cbowen2
cbowen2 is offline   Reply With Quote
Old 07-26-2005, 08:31 PM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Try adding squar brackets '[]' around the password field, as i'm sure it's a reserved word:
Code:
cmdString2 = string.Format( "UPDATE USERS SET [password]='" & txtConfirmPassword.Text & "' WHERE username='" & dtrResults("username") & "'")
Good luck
__________________
-Brando
Why using tables for eating is stupid!

Last edited by Brandoe85; 07-26-2005 at 08:35 PM..
Brandoe85 is offline   Reply With Quote
Old 07-26-2005, 09:36 PM   PM User | #3
cbowen2
New to the CF scene

 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
cbowen2 is an unknown quantity at this point
Thank You!

You are a life saver, thank you very much!
cbowen2 is offline   Reply With Quote
Old 02-17-2011, 04:24 PM   PM User | #4
sirjoshua00
New to the CF scene

 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sirjoshua00 is an unknown quantity at this point
thanks

thank you Brando

that is also my problem and when i read it i put a bracket on every field i want to update
sirjoshua00 is offline   Reply With Quote
Old 03-09-2011, 10:48 AM   PM User | #5
geraldmaybe
New to the CF scene

 
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
geraldmaybe is an unknown quantity at this point
Thanx ! really this is a big problem.very thanx.


http://homefitnessandnutrition.co.cc...cycling-skill/
geraldmaybe is offline   Reply With Quote
Old 04-26-2011, 04:49 AM   PM User | #6
pipelian
New to the CF scene

 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pipelian is an unknown quantity at this point
Hi

I have a similar problem..,,this is my code

Dim cb As New OleDb.OleDbCommandBuilder(da)

ds.Tables("Inventory").Rows(inc).Item(0) = txtProductName.Text
ds.Tables("Inventory").Rows(inc).Item(1) = txtRefNumber.Text
ds.Tables("Inventory").Rows(inc).Item(2) = txtCategory.Text
ds.Tables("Inventory").Rows(inc).Item(3) = txtQuantity.Text
ds.Tables("Inventory").Rows(inc).Item(5) = txtLotNumber.Text

da.Update(ds, "Inventory")

MsgBox("Data updated")
End Sub


Im able to run my Form, just when I want to update the changes made into the field "Lot Number" I get the same error.

Any help?
pipelian is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:24 PM.


Advertisement
Log in to turn off these ads.