Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Problem sending combo box text as a parameter to MS SQL Posted by praneeth on 17 May 2004 at 2:41 PM
hello ppl,

i am having a problem with MS SQL....

Dim s As String
s = Trim(Combo1.Text)
rs3.Open "select * from ' " + s + " ' where mag_id='" + Text1.Text + "'", con, adOpenDynamic, adLockOptimistic

i need to send the combo1.text as parameter but MS SQL dosent accept it directly....... so i tried to store it in a variable and then send that as a parameter....... but this also dosent work....

can anyone just tell me how i can capture the combobox text and send it as a fiels in the MS SQL querry.

waiting for ur help,
bye
Report
Re: Problem sending combo box text as a parameter to MS SQL Posted by GideonOmega on 18 May 2004 at 5:37 AM
: hello ppl,
:
: i am having a problem with MS SQL....
:
: Dim s As String
: s = Trim(Combo1.Text)
: rs3.Open "select * from ' " + s + " ' where mag_id='" + Text1.Text + "'", con, adOpenDynamic, adLockOptimistic
:
: i need to send the combo1.text as parameter but MS SQL dosent accept it directly....... so i tried to store it in a variable and then send that as a parameter....... but this also dosent work....
:
: can anyone just tell me how i can capture the combobox text and send it as a fiels in the MS SQL querry.
:
: waiting for ur help,
: bye
:


you can use the parameters collection to send a parameter to msSQL, but you don't need that here -->
rs3.Open "select * from " & s & " where mag_id='" & Text1.Text & "'", con, adOpenDynamic, adLockOptimistic

you don't want single quotes around your table name -- that is used to pass a string value to a field - also try using ampersands as above instead of +

C:\Dos
C:\Dos Run
Run Dos Run


Report
Re: Problem sending combo box text as a parameter to MS SQL Posted by praneeth on 19 May 2004 at 10:57 AM
thanx for the help..............it works...........thanx again



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.