Error "Must Declare Scalar Variable @ServerName"

M

Mark

I am really struggling with this, trying to understand why it doesn't work.
I've simplified the code down to the essentials. The GridView displays in
ReadOnly mode just fine, Clicking the "edit" button in the gridview works
just fine, but clicking the "Delete" button gives the error "Must Declare
Scalar Variable @ServerName" yet the code in the UpdateCommand and
DeleteCommand are essentially the same!

I must be missing something basic but I just can't see it, can someone
please point it out?
Mark



<%@ page language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<body>
<asp:SqlDataSource ID="RWServerInfoDB" runat="server"
ConnectionString="<%$ ConnectionStrings:RWSqlConnectionString %>"
SelectCommand="SELECT * FROM SERVERINFO"
UpdateCommand="Update SERVERINFO SET
ServerName=@ServerName,
FacCode=@FacCode
WHERE ServerName=@ServerName"
DeleteCommand="DELETE From SERVERINFO
WHERE ServerName=@ServerName">
</asp:SqlDataSource>
<form runat="server">
<asp:GridView ID="DV" DataSourceID="RWServerInfoDB" runat="server"
AutoGenerateColumns="False"
AutoGenerateEditButton="True"
AutoGenerateDeleteButton="True">
<columns>
<asp:BoundField DataField="ServerName" HeaderText="Server Name"/>
<asp:BoundField DataField="FacCode" HeaderText="Facility Code" />
</columns>
</asp:GridView>
</form>
</body>
</html>
 
M

Mark

Does anyone have any ideas, its got to be something really basic, the delete
code is only one line long but it looks just fine to me.
Mark
 

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

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top