Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 What is wrong with this update statement :S

Author  Topic 

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-18 : 14:01:03
cmd.CommandText = "UPDATE Users SET User_email=" + mail_textbox.Text + " WHERE User_ID = " + usr.User_ID;

It gives me an error saying I give it an invalid column and gives the usr.User_ID's value >.<

jleitao
Posting Yak Master

100 Posts

Posted - 2012-07-18 : 14:07:24
d.CommandText = "UPDATE Users SET User_email='" + mail_textbox.Text + "' WHERE User_ID = " + usr.User_ID;
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-18 : 14:15:51
It still says the column name is invalid :(
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-18 : 14:37:59
I dunno but User_ID is the primary key (is identity) does it have anything to do with it?
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-18 : 15:00:56
cmd.CommandText = "UPDATE Users SET User_email = '" + mail_textbox.Text + "' WHERE User_ID = '" + usr.User_ID+"'"
Did the trick :)

Thanks for the suggestion, I just had to cover the User_ID with ' as well.
:)
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-18 : 15:02:47
Ok it still does it.
Seems it doesn;t like the value....

I try to enter admin@gmail.com
Maybe it doesn;t like @ or gmail or admin@ :S
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-18 : 15:09:27
Oops didn;t mean to post a link.
Anyway it DOES work sorry for spamming ._.;
There was another part I had to add it.

I had such queries on other pages with the ' mark and they seem to work fine :S

Maybe I had it and didn;t notice.
And numbers don;t need it?
I know I didn;t add ' when I was dealing with numeric ids.
Go to Top of Page
   

- Advertisement -