Problem with asp.net 2.0

R

RichardF

Not sure if ths is the right place, but I couldn't find a group for
asp.net 2.0 beta.

I am having a problem with updating databases using the data grid. I
have the following code...

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"
SelectCommand="Select * From Customers"
UpdateCommand="UPDATE Customers SET CompanyName =
@CompanyName, Country = @Country, Region = @Region WHERE (CustomerID =
@CustomerID)"
DeleteCommand="DELETE FROM Customers WHERE (CustomerID =
@CustomerID)"

ConnectionString="Server=(local);Trusted_Connection=True;Integrated
Security=SSPI;Persist Security Info=True;Database=Northwind"
ProviderName="System.Data.SqlClient">
<UpdateParameters>
<asp:parameter Name="CustomerID" Type="String" />
<asp:parameter Name="CompanyName" Type="String" />
<asp:parameter Name="Country" Type="String" />
<asp:parameter Name="Region" Type="String" />
</UpdateParameters>
<DeleteParameters>
<asp:parameter Name="CustomerID" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>

After clicking edit, making a change and then clicking update I get
the error...

Must declare the variable '@CustomerID'.

(Same happens when I try to Delete as well)

Any ideas?

RichardF
 
R

RichardF

I assume someone else will hit this problem too, so here is the
solution, directly from the author Bill Evjen. As is common with Beta
products, Microsoft "tweaked" a few things!

Change the Update command to...

UpdateCommand="UPDATE Customers SET CompanyName = @CompanyName,
Country = @Country, Region = @Region WHERE (CustomerID =
@original_CustomerID)

....note the "original_" prefix on the CustomerID parameter.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top