Problem sending combo box text as a parameter to MS SQL

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

Comments

  • : 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 +
    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]

  • thanx for the help..............it works...........thanx again
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories