By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,239 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Error "Must Declare Scalar Variable @ServerName"

P: n/a
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>

Jan 25 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
"Mark" <ma*********@verizon.netwrote in message
news:D8**********************************@microsof t.com...
>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>
Jan 28 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.