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>
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>