Update query not working in VB.NET

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Apr 2009
Posts: 3
Reputation: ahmedlibrian is an unknown quantity at this point 
Solved Threads: 0
ahmedlibrian ahmedlibrian is offline Offline
Newbie Poster

Update query not working in VB.NET

 
0
  #1
Apr 3rd, 2009
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=' xyz@hotmail.com '

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

/Ahmed
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 1
Reputation: Rengarajan.pprs is an unknown quantity at this point 
Solved Threads: 0
Rengarajan.pprs Rengarajan.pprs is offline Offline
Newbie Poster

Re: Update query working in VB.NET

 
0
  #2
Apr 4th, 2009
Daer Friend

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

new Codings

UPDATE mainadmin SET firstname = ' "& txt1.text &" ', lastname = ' "& txt2.text &" ', passvord = ' "& txt3.text &" ' WHERE username=' xyz@hotmail.com '
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 5
Reputation: maczoon is an unknown quantity at this point 
Solved Threads: 2
maczoon maczoon is offline Offline
Newbie Poster

Re: Update query not working in VB.NET

 
0
  #3
Apr 4th, 2009
Daer Friend

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

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 ' & "
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 3
Reputation: ahmedlibrian is an unknown quantity at this point 
Solved Threads: 0
ahmedlibrian ahmedlibrian is offline Offline
Newbie Poster

Re: Update query not working in VB.NET

 
0
  #4
Apr 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 3
Reputation: ahmedlibrian is an unknown quantity at this point 
Solved Threads: 0
ahmedlibrian ahmedlibrian is offline Offline
Newbie Poster

Re: Update query not working in VB.NET

 
0
  #5
Apr 5th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC