passing a parameter into a select command
-
i build something like a search function. but he doesn't fill my parameter the parameter does get a value.. but when he should put it into my select command he give the error: No value given for one or more required parameters. so.. this is a little peace of my select command
WHERE (T075_BORGTOCHTNUMMER_1 LIKE VAL)
en this is my code that should fill the parameter "VAL"string val; if (textBox1.Text != string.Empty) { val = textBox1.Text; } else { val = "%"; } this.dBANBM_T075_BORGTOCHTTableAdapter.Fill(this.testdb1DataSet.DBANBM_T075_BORGTOCHT);
hope some one can help or give some advise -
i build something like a search function. but he doesn't fill my parameter the parameter does get a value.. but when he should put it into my select command he give the error: No value given for one or more required parameters. so.. this is a little peace of my select command
WHERE (T075_BORGTOCHTNUMMER_1 LIKE VAL)
en this is my code that should fill the parameter "VAL"string val; if (textBox1.Text != string.Empty) { val = textBox1.Text; } else { val = "%"; } this.dBANBM_T075_BORGTOCHTTableAdapter.Fill(this.testdb1DataSet.DBANBM_T075_BORGTOCHT);
hope some one can help or give some adviseIt depends on what database you use, but normally you can create commands like this:
SELECT * FROM DBANBM_T075_BORGTOCHT WHERE Id = @Id
And insert parameters into the command like this:SqlCommand cmd = new SqlCommand(query,connection); cmd.AddParameterWithValue("@Id",1);
Be adviced: I do this without the help of a little intellisense ;P So the syntax of the AddParameterWithValue may vary. WM.
What about weapons of mass-construction? -- modified at 3:33 Wednesday 10th May, 2006 For an access database the parameters have a questionmark as placeholder and are position dependend. -
It depends on what database you use, but normally you can create commands like this:
SELECT * FROM DBANBM_T075_BORGTOCHT WHERE Id = @Id
And insert parameters into the command like this:SqlCommand cmd = new SqlCommand(query,connection); cmd.AddParameterWithValue("@Id",1);
Be adviced: I do this without the help of a little intellisense ;P So the syntax of the AddParameterWithValue may vary. WM.
What about weapons of mass-construction? -- modified at 3:33 Wednesday 10th May, 2006 For an access database the parameters have a questionmark as placeholder and are position dependend.i use a access database and soon i will use a oracle database. but what do you mean with "are position dependend"?
-
i use a access database and soon i will use a oracle database. but what do you mean with "are position dependend"?
If you have
INSERT INTO Tbl (Id,Value) (?,?)
The first parameter to add has to be the parameter that is first mentioned in the command. You cant first add the parameter for the Value and the parameter for Id after that. WM.
What about weapons of mass-construction? -
If you have
INSERT INTO Tbl (Id,Value) (?,?)
The first parameter to add has to be the parameter that is first mentioned in the command. You cant first add the parameter for the Value and the parameter for Id after that. WM.
What about weapons of mass-construction?oh i see thanks error: Syntax error (missing operator) in query expression '(T075_BORGTOCHTNUMMER_1 = ?VAL)'. what operator does he need? i've tried '' and [] and stuf like that. the other code i didn't change.
-
oh i see thanks error: Syntax error (missing operator) in query expression '(T075_BORGTOCHTNUMMER_1 = ?VAL)'. what operator does he need? i've tried '' and [] and stuf like that. the other code i didn't change.
Use this expression: '(T075_BORGTOCHTNUMMER_1 = ?)'. In Access you can't name the parameters. Thats the reason you have to add their values in the right order.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Use this expression: '(T075_BORGTOCHTNUMMER_1 = ?)'. In Access you can't name the parameters. Thats the reason you have to add their values in the right order.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
No value given for one or more required parameters. how do i set the value of my textbox to this parameter?