Parameter Error

G

Guest

I am writing a VB program, and on one particular form, I want to update a database based on a calculation, and the user inputting a number in a combo box on a form. In my table, the field names are name, 1-17, and total.

Here is a sample of the parameter definitions

Dim prm4 As OleDb.OleDbParameter = _
dap2.UpdateCommand.Parameters.Add("@name", _
System.Data.OleDb.OleDbType.VarChar, 25, "name")

Dim prm5 As OleDb.OleDbParameter = _
dap2.UpdateCommand.Parameters.Add("@1", _
System.Data.OleDb.OleDbType.Integer, "1")

all the way to 17, and total.

1st question: When I run the program, the user enters 1 in the combo box, I receive:
Parameter ?_2 has no defaut value.

I want the program to leave the value in field 2 in the database alone.

2nd question:

I dont want to write 17 sets of code for the 17 options a user can choose. I want to write a statement something like:
drw2("1") = xx
but I want the 1 to be cboChoice.Text, but I do not know how to format the command.

Please help.
 
W

William \(Bill\) Vaughn

Can we see the SQL query with the parameter markers?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Tom Nowak said:
I am writing a VB program, and on one particular form, I want to update a
database based on a calculation, and the user inputting a number in a combo
box on a form. In my table, the field names are name, 1-17, and total.
Here is a sample of the parameter definitions

Dim prm4 As OleDb.OleDbParameter = _
dap2.UpdateCommand.Parameters.Add("@name", _
System.Data.OleDb.OleDbType.VarChar, 25, "name")

Dim prm5 As OleDb.OleDbParameter = _
dap2.UpdateCommand.Parameters.Add("@1", _
System.Data.OleDb.OleDbType.Integer, "1")

all the way to 17, and total.

1st question: When I run the program, the user enters 1 in the combo box, I receive:
Parameter ?_2 has no defaut value.

I want the program to leave the value in field 2 in the database alone.

2nd question:

I dont want to write 17 sets of code for the 17 options a user can choose.
I want to write a statement something like:
 
W

William \(Bill\) Vaughn

drw2("1") = MyTextBox.Text

If drw2 is a Parameter object, it handles any string framing and other
issues for you.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Tom Nowak said:
I figured out the 1st one, but not the 2nd question:

2nd question:

I dont want to write 17 sets of code for the 17 options a user can choose.
I want to write a statement something like:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top