Thursday, March 22, 2012

ERROR in Where Cluase

Hello EveryBody,

I have a little problem in Sql Statement .. When I am adding a Where condtion to my sql statement ..I got an error shown in the pic blew :

I am waiting for your solution

Best regards,

It means that you have an error in your WHERE clause.Big Smile

What is the complete SELECT statement?

Don

|||

Good eveningdonkielySmile,

This is my SQL Statement:

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID= @.CategoryID

and this is the erro shown in pic :-

Thank you for your concern

|||

Ah. I'm glad you sent the image. There cannot be a space between the @. and the CategoryID on the right side of the = sign.

Don

|||

Sad

Unfortunately, I was trying with no space ..but the same error happen >>

Shown in pic blew:-

Thanks Don

|||

ban:

This is my SQL Statement:

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID= @.CategoryID

When I copy and paste that into Query Analyzer and run it against the Northwind database I receive no error. Are you sure that is your exact SQL statement?

|||

Dear tmorton,

yes , I am .It is the exact SQL Statemet .

but I am thinking maybe there is missing file on my program or somthing wrong with my keyboard.

I do not konw ,but this is not the first time that error happen to me ,every time I use WHERE Cluase .

I hop to find the solution for it .

anyway thanks to trying help meSmile

|||

Just a silly question, and don't kill me if it sounds really stupid to ask this please!

You are using SQL Server with the default sql server provider, yes?

|||

shadosIndifferent

OoOoOOOOOh God I am just a beginner programmer in ASP.NET ... I am so confuse

I did not get it your Q , but I am using a Microsoft Visual Studio .Net 2005 (Full Edition)

This version include Microsoft SQL Server 2005

Note : I can run SQL Statement with this program but I can not use WHERE Clause when it is taking a parameter

I appreciateyour help

|||

Okie, that answer my question, you are. All good then, I really don't get what the issue is. I was asking, because different databases have issues with SQL statements like the one you're writting (with parameters in the where clause), so I thought... But thats not the problem, so back to the drawining board >.<

|||

shados,

so back to the drawining boardTongue Tied

What do you mean by that ?

|||I just meant that my idea was wrong :)|||

Hellow againBig Smile,

I find the solution for my problem>>>shown in pic blew :-

Not: I am using Microsoft Acess DataBase.

Speical Thanks to >>donkiely ,tmorton,shados

for more info:-

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=874535&SiteID=1&mode=1

Have a nice day!

|||

ban:

I find the solution for my problem

That's great!!

ban:

Not: I am using Microsoft Acess DataBase.

This is the SQL Server forum. Next time please post in the Access forum. You would have had an answer days agoWink

|||

Gah, thats why I asked if you were using SQL Server :) In databases like MS Access, PervasiveSQL, a lot of databases accessed through ODBC, etc, you have to use the ? placeholder instead of @.variablename...

Indeed, since this is a SQL Server forum, we all assumed you were using SQL Server, hahahaha. Ahh well, glad you found your problem.

sql

No comments:

Post a Comment