473,414 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Error "Must Declare Scalar Variable @ServerName"

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
1 2958
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Boris Zakharin | last post by:
I have the following code upon which I receive the error "Must declare the variable '@job_id'". --Begin Code -- OleDbConnection conDetail = new OleDbConnection("Provider=SQLOLEDB.1;Integrated...
3
by: Ken Adeniji | last post by:
Must declare the scalar variable '@FirstName' ContactGridViewWebForm.aspx <aspqlDataSource RunAt="server" ID="SqlDataSourceContact" ...
2
by: Oded Dror | last post by:
Hi there, Please take a look at the source code and tell me whats wrong? Imports System.Data Imports System.Data.SqlClient Partial Class Test Inherits System.Web.UI.Page Const conString As...
1
by: AndrewD | last post by:
when the following SELECT is executed via A cursor to SQL 2005 it works SELECT * FROM LCTRY WHERE LANGUAGE = 'EN' AND CTRY_CODE = :CTRY BUT SELECT * FROM LCTRY WHERE CTRY_CODE = :CTRY...
1
by: Rama Jayapal | last post by:
the following is my code can anybody rectify my problem that i get when running my application "Must declare scalar variable @ID" <asp:GridView ID="GridView1" DataKeyNames="ID" runat="server"...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
2
by: saravana784 | last post by:
USE GO /****** Object: StoredProcedure . Script Date: 06/09/2007 20:15:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO
0
by: =?Utf-8?B?V0pC?= | last post by:
I'm trying to understand the full interaction between controls on a formview that are bound to a SQLDataSource and the binding of the data using ASP.Net 2.0. When I set ConflictDetection to...
1
by: Tony M | last post by:
vs 2005 - vb .net - web forms - xp pro Can't figure out why I keep getting the error Must declare the scalar variable "@CheckUser". The error happens on SqlDA.Fill(SqlDS). Just trying to make...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.