473,568 Members | 2,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.SqlClie nt" %>
<html>
<body>
<asp:SqlDataSou rce ID="RWServerInf oDB" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:RWSqlConnect ionString %>"
SelectCommand=" SELECT * FROM SERVERINFO"
UpdateCommand=" Update SERVERINFO SET
ServerName=@Ser verName,
FacCode=@FacCod e
WHERE ServerName=@Ser verName"
DeleteCommand=" DELETE From SERVERINFO
WHERE ServerName=@Ser verName">
</asp:SqlDataSour ce>
<form runat="server">
<asp:GridView ID="DV" DataSourceID="R WServerInfoDB" runat="server"
AutoGenerateCol umns="False"
AutoGenerateEdi tButton="True"
AutoGenerateDel eteButton="True ">
<columns>
<asp:BoundFie ld DataField="Serv erName" HeaderText="Ser ver Name"/>
<asp:BoundFie ld DataField="FacC ode" HeaderText="Fac ility Code" />
</columns>
</asp:GridView>
</form>
</body>
</html>

Jan 25 '08 #1
1 2968
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*********@ve rizon.netwrote in message
news:D8******** *************** ***********@mic rosoft.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
DeleteComman d 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="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.SqlClie nt" %>
<html>
<body>
<asp:SqlDataSou rce ID="RWServerInf oDB" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:RWSqlConnect ionString %>"
SelectCommand=" SELECT * FROM SERVERINFO"
UpdateCommand=" Update SERVERINFO SET
ServerName=@Ser verName,
FacCode=@FacCod e
WHERE ServerName=@Ser verName"
DeleteCommand=" DELETE From SERVERINFO
WHERE ServerName=@Ser verName">
</asp:SqlDataSour ce>
<form runat="server">
<asp:GridView ID="DV" DataSourceID="R WServerInfoDB" runat="server"
AutoGenerateCol umns="False"
AutoGenerateEdi tButton="True"
AutoGenerateDel eteButton="True ">
<columns>
<asp:BoundFie ld DataField="Serv erName" HeaderText="Ser ver Name"/>
<asp:BoundFie ld DataField="FacC ode" HeaderText="Fac ility 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
3137
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 Security=SSPI;Persist Security Info=False;Initial Catalog=ACRPPhilly;Data Source=COMPUSA\\VSdotNET;Use Procedure for Prepare=1;Auto...
3
7785
by: Ken Adeniji | last post by:
Must declare the scalar variable '@FirstName' ContactGridViewWebForm.aspx <aspqlDataSource RunAt="server" ID="SqlDataSourceContact" ConnectionString="server=localhost;database=WordEngineering;Integrated Security=SSPI;" ProviderName="System.Data.OleDb"
2
6633
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 String = "Data Source=.;Initial Catalog=Northwind;Integrated Security=True"
1
7221
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 AND LANGUAGE = 'EN'
1
1798
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" AutoGenerateColumns="False" BackImageUrl="~/App_Themes/SkinFile/back1.jpg" BorderColor="Teal" BorderStyle="Solid"...
0
8294
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 records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically...
2
23881
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
1345
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 CompareAllValues, I get the error: Must declare the scalar variable xxxx on fields that are not represented by controls in the formview templates. If all...
1
8275
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 sure EMail address doesn't exist in database before I insert data. Connection string and everything else is correct. If I use Dim SQL = "Select *...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.