ODBC Command parameters

I am using VS2005. I have went through the Command Wizard to set up a ODBC Command with my custom query. I am not sure how to setup the query so that it gets the parameter from a combobox to insert into my query.

When I am in the Database Expert dialog box and I right-click on the Command and select "edit command". It brings up the dialog box to edit my query statement and create parameters. This is where I am stuck. How do I get it to grab the parameter from what is selected in the combobox on my WinForm, to generate the report

Such as the part of my query " WHERE number LIKE 'WinForm Combobox Text' "

Is there a certain syntax to write in the query statement to get the parameter from the combo box

I tried this, but does not work: WHERE number LIKE {me.cboNumber.text}

I have searched the net to try and find an example of how to do it and could not find anything. Any help would be appreciated.




Answer this question

ODBC Command parameters

  • Choon Meng

    Yes; your SQL statement is not related to your code, they are totally separate.
  • Tomas35595

    Would that still apply for VB instead of C#

  • lknm

    Parameters in a sql statement are not directly related to your C# code; you cannot use identifiers from your form in a sql statement. Instead, use a named parameter in your sql (like @number), then add a parameter to the command object's Parameters collection, with your parameter name (i.e. @number) and the value you want to pass for that parameter (i.e. cboNumber.Text).

  • ODBC Command parameters