943,822 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1644
  • VB.NET RSS
Apr 3rd, 2009
0

Update query not working in VB.NET

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ahmedlibrian is offline Offline
4 posts
since Apr 2009
Apr 4th, 2009
0

Re: Update query working in VB.NET

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 '
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rengarajan.pprs is offline Offline
1 posts
since Apr 2009
Apr 4th, 2009
0

Re: Update query not working in VB.NET

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 ' & "
Reputation Points: 11
Solved Threads: 2
Newbie Poster
maczoon is offline Offline
5 posts
since Mar 2009
Apr 4th, 2009
0

Re: Update query not working in VB.NET

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ahmedlibrian is offline Offline
4 posts
since Apr 2009
Apr 5th, 2009
0

Re: Update query not working in VB.NET

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ahmedlibrian is offline Offline
4 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: I want to manipulate the registry key values through a vb.net application
Next Thread in VB.NET Forum Timeline: Writing to Access database using VB.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC