I am getting the same error even when I do a direct copy from MSDN material
MSDN CODE:
<asp:sqldatasource runat="server" id="MySource"
connectionstring="SERVER=(local);DATABASE=northwind;Integrated
Security=SSPI;"
datasourcemode="DataReader"
selectcommand="SELECT employeeid, firstname, lastname, photo
FROM employees"
updatecommand="UPDATE employees SET firstname=@firstname,
lastname=@lastname WHERE employeeid=@employeeid"
deletecommand="DELETE employees WHERE employeeid=@employeeid">
</asp:sqldatasource>
<asp:gridview runat="server" id="MyGridView" datasourceid="MySource"
datakeynames="employeeid" autogeneratecolumns="false"
autogenerateeditbutton="true" autogeneratedeletebutton="true">
<columns>
<asp:boundfield datafield="firstname" headertext="First" />
<asp:boundfield datafield="lastname" headertext="Last" />
<asp:imagefield datafield="photo" headertext="Picture" />
</columns>
</asp:gridview>
ERROR: System.Data.SqlClient.SqlException: Must declare the variable
'@employeeid'.
other code snippets from other sources produce similar results..
//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////
///////\\\\\\\\\\\\\\\\\\\\\\\\
[quoted text, click to view] "PiotrF" <PiotrF@discussions.microsoft.com> wrote in message
news:FCF2E79C-DA31-4DDB-92D9-2BB9DBCAA934@microsoft.com...
> I am testing ASP.NET 2.0 with MS SQL 2000. I get server error: "Exception
> Details: System.Data.SqlClient.SqlException: Must declare the variable
> '@KEY'" after record updating in GridView or DetailsView. I do not get
this
> message when I use MS ACCESS. I do not get this message with MS SQL when I
do
> not use DataKeyNames="KEY" in <asp:GridView ../> or <asp:DetailsView .>.
What
> should I change?