Passing Parameters into a select query C#

rmokkenstorm

Active member
Joined
Feb 20, 2006
Messages
31
im building a program wich have a search function.
the user fills in a value in a textbox and presses the button.
now the given value should pass to the select query

C#:
           string VAL;


            if (textBox1.Text != string.Empty)
            {
                VAL = textBox1.Text;
            }
            else
            {
                VAL = "%";

            }
          
          this.dBANBM_T075_BORGTOCHTTableAdapter.Fill(this.testdb1DataSet.DBANBM_T075_BORGTOCHT);

and the select query is:
WHERE (T075_BORGTOCHTNUMMER_1 LIKE ?)"
i use a acces database
but when i execute this he says that there is no value for the paratmeter

can anyone help me?
 
Last edited by a moderator:
You need to pass the VAL string into the query, if you are using the 2005 table adapter designer (and it looks like you are) then you can use a wizard to add a query to the adapter - give it your parameterised SQL as the source and it will generate a wrapper method that will allow you to pass the parameter in.
 
I put down a new query with the select :
WHERE T075_BORGTOCHTNUMMER_1 LIKE ?

and the following fill command:
this.dBANBM_T075_BORGTOCHTTableAdapter.FillBy1(this.testdb1DataSet.DBANBM_T075_BORGTOCHT);

he returns me the error:

No overload for method FillBy1 takes 1 arguments
 
Thats because the function you just created expects you to pass in a second parameter - put VAL in there and it will use the variable as a parameter for the query.
 
Back
Top