I have a button on an aspx page. When the user clicks the button I would
like to add a new row to an existing table in my Access database. The table
is Ante_Admin. The name of the key field is AnteNum, I would like to set
the value of AnteNum to MyVal.
In code behind on an aspx page I have:
protected void Button1_Click1(object sender, EventArgs e)
{
string MyVal = "2";
AccessDataSource AccessDataSource2 = new AccessDataSource();
AccessDataSource2.DataFile =
System.Configuration.ConfigurationManager.AppSettings["ConnString"];
Parameter Param = new Parameter("AnteNum");
Param.DefaultValue = MyVal;
AccessDataSource2.SelectParameters.Add(Param);
AccessDataSource2.InsertCommand = "INSERT INTO Ante_Admin (AnteNum) VALUES
(@dotnet.itags.org.Param)";
AccessDataSource2.Insert();
}
When the button is pressed, I get the following error message: No value
given for one or more required parameters.
This probably exhibits my lack of understanding of Parameters. I am not
able to set the value of Param to MyVal. Any suggestions including sample
code would be appreciated.
JimTry replaceing @.Param with (?) in the Insert command you are
passing.....
I am sure it will work.
> I have a button on an aspx page. When the user clicks the button I would
> like to add a new row to an existing table in my Access database. The tab
le
> is Ante_Admin. The name of the key field is AnteNum, I would like to set
the
> value of AnteNum to MyVal.
> In code behind on an aspx page I have:
> protected void Button1_Click1(object sender, EventArgs e)
> {
> string MyVal = "2";
> AccessDataSource AccessDataSource2 = new AccessDataSource();
> AccessDataSource2.DataFile =
> System.Configuration.ConfigurationManager.AppSettings["ConnString"];
>
> Parameter Param = new Parameter("AnteNum");
> Param.DefaultValue = MyVal;
> AccessDataSource2.SelectParameters.Add(Param);
> AccessDataSource2.InsertCommand = "INSERT INTO Ante_Admin (AnteNum) VALUES
> (@.Param)";
> AccessDataSource2.Insert();
> }
> When the button is pressed, I get the following error message: No value gi
ven
> for one or more required parameters.
> This probably exhibits my lack of understanding of Parameters. I am not a
ble
> to set the value of Param to MyVal. Any suggestions including sample code
> would be appreciated.
> Jim
This is also a standard Access way of saying "I don't know that column
you specified". Does "AnteNum" really exist (typo somewhere?)
Hans Kesting
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment