Simple SQL

  • Thread starter Thread starter Jim McGivney
  • Start date Start date
J

Jim McGivney

In ASP 2.0

I have an access database, with a table named comments whose primary key is
an integer field named ID, and two string fields names Comment1 and
Comment2.

I am trying to use a QueryStringParameter to update my table. This all
should be simple SQL, but I am having a problem.

If possible please suggest some code to help me with this C# code-behind.

When I run

int FileIDNum = 2;
QueryStringParameter queryStr = new QueryStringParameter("ID", "FileIDNum");
AccessDataSource1.SelectParameters.Add(queryStr);
AccessDataSource1.UpdateCommand = "UPDATE Comments SET Comment1='Billy',
Comment2='Bob' WHERE ID=?";
AccessDataSource1.Update();

I get the following error message:

Server Error in '/XML_2' Application.
No value given for one or more required parameters.

I also get a message that FileIDNum has been initialized, but is not used.



Thanks in advance for you help,
Jim
 
Try using this sample below
Hope that helps
Patrick

<asp:AccessDataSource id="ProductsSource" Runat="Server"
DataFile="../Databases/eCommerce.mdb"

SelectCommand="SELECT * FROM Products"

UpdateCommand="UPDATE Products SET ItemType=@ItemType,
ItemDescription=@ItemDescription
WHERE ItemNumber=@ItemNumber"
/>

<asp:AccessDataSource id="TypeSource" Runat="Server"
DataFile="../Databases/eCommerce.mdb"
SelectCommand="SELECT DISTINCT ItemType FROM Products ORDER BY ItemType"/>
 
In ASP 2.0
I have an access database, with a table named comments whose primary key is
an integer field named ID, and two string fields names Comment1 and Comment2.

I am trying to use a QueryStringParameter to update my table. This all
should be simple SQL, but I am having a problem.

If possible please suggest some code to help me with this C# code-behind.

When I run

int FileIDNum = 2;
QueryStringParameter queryStr = new QueryStringParameter("ID", "FileIDNum");

Are you sure you need the quotes around "FileIDNum"? It looks to me
like you are defining a parameter named "ID" with the string value
"FileIDNum"! Try: new QueryStringParameter("ID", FileIDNum);

Hans Kesting
 

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

Back
Top