SQL Server :: Select Count Query And Parameters - Error: "Must Declare The Scalar Variable "@KategorijaID"."?

Sep 18, 2010

I have a problem with SELECT COUNT query in ASP.net. I want to create CMS with articles which have categories (which have the option to be deleted). The problem is that I want to get the number of articles within the specified category so if there aren't any articles with the specified category I can proceed with the category deletion.I have the following code:

[Code]....

After I click the button "Obriši" (Delete) I receive the following error: "Must declare the scalar variable "@KategorijaID"." I understand that the problem is with parameter, but I don't know how to correct it to use it for both the "command" and "brisanje" SQLCommands.

View 9 Replies


Similar Messages:

SQL Server :: Insert Query - Error Must Declare The Scalar Variable "@FirstName"?

Oct 25, 2010

I am attempting to do an insert query on a webpage for a simple member registration form I have created in vs2010. I have done this type of thing before without problem using an access database, but now I'm using a sqlexpress db created from within vs2010. This is the screenshot of my insert query:

Now, when I execute this query in the form, I get an error that says:

Must declare the scalar variable "@FirstName".Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@FirstName".

Source Error:

[Code]....

Source File: C:UsersCJ PerryDocumentsMy DropboxWebSitesCJ's Test WebsiteRegister.aspx Line: 51 Stack Trace:

[Code]....

Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

At first I just had my query with all ?'s instead of @FirstName, etc in the insert statement itself, but I got an error on that as well but it was different, it just said syntax error near "?" or something to that effect. If I manually perform this query in the builder, and it pops up a window that asks for values on everything, I put something into each field and the insert works great. It just won't work with these parameters for some reason. Can someone advise what I need to do?

View 5 Replies

SQL Server :: Using SQL INSERT Command With DataGrid - Must Declare The Scalar Variable Error

Mar 28, 2011

OK, this may be a little difficult to explain, so I will try my best and post the code I currently have.

I have a table with a list of usernames. I have the list of usernames displayed on a page through a GridView. What I am attempting to do is for each username in the column "adminUsernames", I need to insert a set of values in another database table for EACH "adminUsernames" that exists. Example: There are 2 adminUsernames vales in 2 seperate rows. These are "Admin 1" and "Admin 2". For each adminUsername values (Admin 1, Admin 2), I need a row interted in another database table. Maybe the code that I have (that does not work) will help you see what is happening:

[Code]....

I keep receiving this error when running: [Code]....

View 3 Replies

DataSource Controls :: Must Declare The Scalar Variable With Name Parameters?

Mar 1, 2011

I'm getting "Must declare the scalar variable "@ShowTypes"." when I try to run the code below.

[Code]....

View 3 Replies

Web Forms :: Error - Must Declare Scalar Variable

Dec 11, 2012

when I am executing an above code and click on button to insert data is shows an error message

as: System.Data.SqlClient.SqlException: Must declare the scalar variable "@imagefile"

Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
Try
If fileupload1.HasFile Then
'getting length of uploaded file

[Code]....

View 1 Replies

SQL Server :: Error "Must Declare The Scalar Variable"

Aug 14, 2010

[Code]....

Error "Must declare the scalar variable"

View 3 Replies

SQL Server :: How To Declare Scalar Variable

Aug 5, 2010

how to Declare scalar variable

[Code]....

View 6 Replies

DataSource Controls :: How To Insert A Picture On A Gridview / The Error - Must Declare The Scalar Variable

Feb 28, 2010

i would like to insert a picture on a gridview, but i allways get the error:

Must declare the scalar variable "@IMAGEM"

somme one can on tihs code ? here is my code:

[code]....

View 13 Replies

Using DataSet In C# Error: Must Declare The Scalar Variable "@city".

Mar 16, 2010

I am trying to fill a dataSet with rows from a table in my SQL Server Express 2008 and I keep getting an error.

Error: Must declare the scalar variable "@city".

Code:
using System;
using System.Data;
using System.Data.SqlClient;
[code].....

The error happens at the adCust.Fill command and I am unsure why. If the variable @city was not declared than why did the WriteLine command work.

View 3 Replies

Forms Data Controls :: Binding DropDownList To GridView - Error / .Must Declare The Scalar Variable "@ProductID"

May 25, 2010

i have two tables in my database, product(productid as pk) and productdetails(productid as fk), in a relationship.i have dropdownlist which on pageload displays data from my product table, showing all product name. AutoPostBack enabled. Its working fine.i have a gridview which should display the productdetails data when i select a value from my dropdown list.i have written the code for the gridview on the selected_index_change event of the drop down list, please correct me this is wrong;here is the code;

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Dim ConString As String [code]...

so when i select the value in the dropdownlist i get this error .Must declare the scalar variable "@ProductID".

View 7 Replies

Web Forms :: Must Declare The Scalar Variable?

Mar 24, 2014

I Am getting error as Must declare the scalar variable "@Imageid" for the following code,while executing,

exec spGetPager  ' ' , ' ', ' 3 ', ' '

In my coding I pass querystring value like 1,2,3 etc

CREATE PROCEDURE spGetPager
@PageNo int = 1,
@ItemsPerPage int = 1,
@Imageid int,

[Code].....

View 1 Replies

DataSource Controls :: Declare The Scalar Variable @txtSubject?

Mar 24, 2011

I can't figure out whats wrong with my contact page. I am getting this error when executing. It complied fine, I see the page as it suppose to. Then I enter all my contact information and click submit I am getting this error. Can someone guide me. Here is the error msg

must declare the scalar variable @txtSubject Here is the part of relevant code

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim ContactDataSource As New SqlDataSource()
ContactDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
ContactDataSource.InsertCommandType = SqlDataSourceCommandType.Text
ContactDataSource.InsertCommand = "INSERT INTO Enquery (EnqSubject,EnqFirstname, EnqLastname,EnqContactNumber,EnqEmail,EnqMsg,EnqDateTimeStamp,EnqIPAddress) values (@txtSubject, @txtFirstname, @txtLastname,@txtPhone,@txtEmail,@txtMsg, @txtDateTimeStamp,@txtIpAddress)"

[Code]....

View 3 Replies

DataSource Controls :: How To Declare Scalar Variable @UserName In Function

Jan 14, 2010

How do I define @UserName in my function:

[Code]....

I believe "UserName" = Me.User.Identity.Name

but I don't know the proper way to add it to the function.

View 6 Replies

Must Declare The Scalar Variable "@EmailAddress" On 'command'.ExecuteNonQuery()

May 18, 2010

I keep getting:

Must declare the scalar variable "@EmailAddress" when I'm debugging and my values aren't being submitted to the DB. Can the eyes of the forum see my error?

[Code]....

[Code]....

View 2 Replies

DataSource Controls :: Must Declare The Scalar Variable "@UserId"?

Mar 30, 2010

am trying to provide users with a number of options, among which, I would like them to see a sum of trips that they have talked about. I have therefore the Trips Table and the Users table. The UserId is the PK of User Table and FK of Trips Table. Trip_Id is PK of Trips Table.In order to see a sum of the number of trips that a user has post, this is the query I have wrote into SQLDATASOURCE:

[Code]....

Everything seems really simple and cannot figure out why when I try to login to test the application , the error I get is: Must declare the scalar variable "@UserId".

View 5 Replies

ADO.NET :: Must Declare The Scalar Variable "@NieuwsID"

Sep 6, 2010

I get the error message: Must declare the scalar variable "@NieuwsID".

<%@ Page Title="" Language="VB" MasterPageFile="~/Nieuws/MasterPageNieuws.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Nieuws_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="../Inloggen.js" type="text/javascript" />
<script type="text/javascript">
function toonPopUp() {.......

View 3 Replies

SQL Server :: Use Row_number Function And Select Count(date_time) From Datos This Query?

Feb 9, 2011

I have many record in my sql table and i want to fetch last row of table.I have used max function but it is very slow

i m using this query-

select pm_name from datos where date_time = (select Max(date_time) from datos) but it takes more time i want to use select count(date_time) from datos this query provide me row number then how can fetch row of this number.

View 11 Replies

SQL Server :: Passing Parameters For Select Query To Another Page

Dec 14, 2010

I have an asp.net site which includes a "search" page that queries an SQL table, then redirects the user to a "results" page where the results of the query are displayed. The parameters for the query are assembled into a string which is the SELECT statement. I've been asked to add additional functionality that requires a secondary search which takes place on the "results" page. How can I pass the parameters from the "search" page to the "results" page so that I can access those parameters in the code behind? Here's the first page code behind (I inherited most of this from another developer):

[Code]....

And the second page--it would be on line 51 that I would need to insert the parameters from the search above:

[Code]....

View 3 Replies

DataSource Controls :: Declare Attribute With Select Top 1 / Error Incorrect Syntax Near The Keyword 'select'

Apr 14, 2010

I will declarate a attribute, but it gives me an error

This query works fine and returns 1 record from type int:

SELECT TOP 1 DataObjectVersionID
FROM tblDataObjectVersionPropertyValueText
WHERE PropValue like CAST('00010281' AS ntext)
ORDER BY DataObjectVersionID DESC

And when I will declarate a attribute/parameter it gives me an error:

DECLARE @dataObjectVersionId INT
SET @dataObjectVersionId = SELECT TOP 1 DataObjectVersionID
FROM tblDataObjectVersionPropertyValueText
WHERE PropValue like CAST('00010281' AS ntext)
ORDER BY DataObjectVersionID DESC

Error message:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'SELECT'.

View 4 Replies

SQL Server :: What If Multiple Output Parameters And Input Parameters And Also Want A Select Table

Feb 16, 2011

[Code]....

When I want to get the output values its okay but I also want returning a table as a result data.But Datareader has no rows.is it possible if I want a returning query result and multiple output values togather ?I wrote a test above.I can get output values as sqlparameters. But Datareader attached to a Gridview is empty.can you detect whats wrong here and it doesnt return a query result.So stored procedure is not standart or ı am doing something wrong.this doesnt raise any exception.but not returning any data.

[code]....

View 8 Replies

C# - Parameters Programaticaly For GridView Select Query?

Jun 24, 2010

I am trying to show a Gridview that lists information in a database based on a query. The query takes a parameter of a string, how do you define what this parameter is. An example of the screen I am stuck at is:http://static.asp.net/asp.net/images/dataaccess/07fig08cs.pngAn example of the code i want to use is:parameter for my object data source select query = OBDS_Query_ParameterOBDS_Query_Parameter = str;

Sorry Im not sure how to explain it...For instance if I have a query that GetAllProducts(String userName); How do i pass or define what userName is when using the data gridview. I am using an Object DataSource and linking the data Gridview to that. I can do this without the object data source and strictly melodramatically like this:

quartz_SongsTableAdapter songsAdapter = new quartz_SongsTableAdapter();
CurrentRole = "admin";
GridView1.DataSource = songsAdapter.GetSongForClient(CurrentRole);
GridView1.DataBind();

View 1 Replies

SQL Server :: Error While Executing A SQL Scalar Function?

Nov 1, 2010

CREATE

FUNCTION dbo.ufnGetProductReport(@Pid
int)

RETURNS int

AS

BEGIN[code]....

This is the program. When im trying to execute it with Select * from dbo.ufnGetProductReport(1)

im getting an error Invalid object name ufnGetProductReport

View 2 Replies

ADO.NET :: Handle Optional Parameters For TableAdapter Select Query

Dec 15, 2010

I'm creating a webpage with serveral web controls to set search parameters for querying an SQL table. My plan is to use a TableAdapter to hold the query. If the user decides not to use one, several, or any of the web controls to filter their search, I want the SELECT to execute without complaining that it doesn't have parameter values. Should my SQL query look like

[Code]....

View 2 Replies

Declare Variable In C# / Use VAR (explicit Declaration) Or The DataType When Declaring A Variable (implicit)?

Sep 7, 2010

Possible Duplicate: Use of var keyword in C# Hi, I am pretty new in C#,I would like to know the best practices in declaring variables.I know it is possible to use VAR (explicit declaration) or the DataType when declaring a variable (implicit).

View 3 Replies

DataSource Controls :: Frustrating In Error "Must Declare The Variable '@Date_Field'"?

May 11, 2010

I am working on this for couple of days but still getting this error message.

SqlCommand sqlInsert;
SqlDataAdapter MySqlAdapter_insert;
SqlCommandBuilder MyBuilder_insert;

[Code]....

View 12 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved