SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 What is wrong with this update statement :S
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lenjaku
Starting Member

13 Posts

Posted - 07/18/2012 :  14:01:03  Show Profile  Reply with Quote
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
Yak Posting Veteran

Portugal
52 Posts

Posted - 07/18/2012 :  14:07:24  Show Profile  Reply with Quote
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 - 07/18/2012 :  14:15:51  Show Profile  Reply with Quote
It still says the column name is invalid :(
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 07/18/2012 :  14:37:59  Show Profile  Reply with Quote
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 - 07/18/2012 :  15:00:56  Show Profile  Reply with Quote
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 - 07/18/2012 :  15:02:47  Show Profile  Reply with Quote
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 - 07/18/2012 :  15:09:27  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000