Insert Function Inserts Only Parameternames
-
Hi all, I'm trying to insert info from text boxes into an Access database using a stored procedure and it seems to some what work. The only problem is values from the text boxes are not entered into the database, instead the parameter names are inserted into the database. The following are how I named, set, and added all my parameters: param = new OleDbParameter("@myvalue", value); oCommand.Parameters.Add(param); My stored procedure takes the following form: INSERT INTO Table( field1,field2) VALUES ('@value1', '@value2'); I have also tried naming, setting, and adding all my parameters using the below method which gave the same exact result as the above method: param = new OleDbParameter(); param.ParameterName="@myvalue"; param.Value=value; oCommand.Parameters.Add(param); Please point out what the problem is if you can spot it, thanks.
-
Hi all, I'm trying to insert info from text boxes into an Access database using a stored procedure and it seems to some what work. The only problem is values from the text boxes are not entered into the database, instead the parameter names are inserted into the database. The following are how I named, set, and added all my parameters: param = new OleDbParameter("@myvalue", value); oCommand.Parameters.Add(param); My stored procedure takes the following form: INSERT INTO Table( field1,field2) VALUES ('@value1', '@value2'); I have also tried naming, setting, and adding all my parameters using the below method which gave the same exact result as the above method: param = new OleDbParameter(); param.ParameterName="@myvalue"; param.Value=value; oCommand.Parameters.Add(param); Please point out what the problem is if you can spot it, thanks.
INSERT INTO Table( field1,field2)
VALUES (@value1, @value2);You don't need the quotes or they'll be interpreted as literal strings.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
INSERT INTO Table( field1,field2)
VALUES (@value1, @value2);You don't need the quotes or they'll be interpreted as literal strings.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Hi all, I'm trying to insert info from text boxes into an Access database using a stored procedure and it seems to some what work. The only problem is values from the text boxes are not entered into the database, instead the parameter names are inserted into the database. The following are how I named, set, and added all my parameters: param = new OleDbParameter("@myvalue", value); oCommand.Parameters.Add(param); My stored procedure takes the following form: INSERT INTO Table( field1,field2) VALUES ('@value1', '@value2'); I have also tried naming, setting, and adding all my parameters using the below method which gave the same exact result as the above method: param = new OleDbParameter(); param.ParameterName="@myvalue"; param.Value=value; oCommand.Parameters.Add(param); Please point out what the problem is if you can spot it, thanks.
ASPnoob wrote:
VALUES ('@value1', '@value2'); ... param.ParameterName="@myvalue";
As mentioned, remove the apostrophes. The names have to match as well.
-
Hi Mark, thanks for replying I've already tried using no quote, single and double quotes without much luck. However, I've just found out that since I'm using Access, I have to use square brackets. My problem is now solved.
Really? How bizarre. Years and years since I used it and I don't recall having to do that. Oh well, relearn something, err, old, every day...
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Really? How bizarre. Years and years since I used it and I don't recall having to do that. Oh well, relearn something, err, old, every day...
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me