954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Update query not working in VB.NET

Hi all,

Well I am new here in Daniweb. First of all hi to all. I have a small problem but it takes me so long to find out its solution but still no use. Actually I am writing an update query in my vb.net page for my website. Here is the query:

UPDATE mainadmin SET firstname = 'abc', lastname = 'xyz', passvord = 'mypassword' WHERE username='xyz@hotmail.com'
Question is when i write like this then it enter these above values and no problem, but when I take values from textboxes then it gives me error, simply dont take the values. Here is what I am writing:

UPDATE mainadmin SET firstname = ' "&txt1.text&" ', lastname = ' "&txt2.text&" ', passvord = ' "&txt3.text&" ' WHERE username=' [email]xyz@hotmail.com[/email] '

This query wont works. Anybody can help me how we can make this query workable. I'll appreciate reply and thaks in advance.

/Ahmed

ahmedlibrian
Newbie Poster
4 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Daer Friend

old codings
UPDATE mainadmin SET firstname = ' "&txt1.text&" ', lastname = ' "&txt2.text&" ', passvord = ' "&txt3.text&" ' WHERE username=' [email]xyz@hotmail.com[/email] '

new Codings

UPDATE mainadmin SET firstname = ' "& txt1.text &" ', lastname = ' "& txt2.text &" ', passvord = ' "& txt3.text &" ' WHERE username=' [email]xyz@hotmail.com[/email] '

Rengarajan.pprs
Newbie Poster
1 post since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Daer Friend

old codings
UPDATE mainadmin SET firstname = ' "&txt1.text&" ', lastname = ' "&txt2.text&" ', passvord = ' "&txt3.text&" ' WHERE username=' [email]xyz@hotmail.com[/email] '

new Codings

UPDATE mainadmin SET firstname = '"& txt1.text &"' , lastname = '"& txt2.text & "' , passvord = '"& txt3.text &"' WHERE username= 'xyz@hotmail.com'
Remember DON'T put space B/W ' & "

maczoon
Newbie Poster
5 posts since Mar 2009
Reputation Points: 11
Solved Threads: 2
 

Hi Guys,

Thanks for your quick reply but let me tell you that I have tried these, it still won't work. And it is taking really my long time to solve it. :(

Any other ways, solutions, options etc.

/Ahmed

ahmedlibrian
Newbie Poster
4 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Hi Guys,
After some my efforts and thinking on the query i make it workable. Its running now properly. What the problem was, I was not converting '"& txt.text & "' to String type. This text box has string value but query was not taking it as string in VB.NET and we need to manually convert it to string type with CStr() function.

Well its working now. By the way thanks for your initial replies.

Regards
/Ahmed

ahmedlibrian
Newbie Poster
4 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You