SQL Query problem

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
Building some queries for my ASP.NET 2.0 Dataset.

I'm new to this all but one of the queries is giving me an error, i'm learning from a tutorial on the ASP.net website so i'm stuck really.

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

"Error in WHERE clause near '@'. Unable to parse query text.

Any help is appreciated, thanks :D
 
Access, could that be why?

I'll will be moving to using SQL Server, but I can't just yet. Please don't suggest just using SQL Server now, I simply can't

:D
 
noob said:
Try this

Code:
SELECT     ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM         Products
WHERE     CategoryID = ?

If that doesn't work try using brackets around the CategoryID = ? like this

WHERE (CategoryID = ?)

No luck - "Enter value parameter for CategoryID"
This is for a DataSet in ASP.NET 2.0. I'm using Visual Web Developer to construct it.

Tutorial said:
The next step is to define the SQL query used to access the data. Since we want to return only those products that belong to a particular category, I use the same SELECT statement from GetProducts(), but add the following WHERE clause: WHERE CategoryID = @CategoryID. The @CategoryID parameter indicates to the TableAdapter wizard that the method we're creating will require an input parameter of the corresponding type (namely, a nullable integer).
 
From an Access Database, in Table Products. I'm using another query on the same database that returns all data with no problems.

Code:
SELECT     ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM         Products
 
It's from the official ASP.NET website.

From what I can tell the point of the tutorial is to basically keep all the fetching of data and so on, seperate from the actual web design. It actually does make quite a lot of sense to be fair. Then when you want the data you simply call on the TableAdapter that you've created which contains the SQL Queries.

I'm stuck now though because what it's telling me to do isn't working ha-ha.

I guess I could just do all this using Access Data Sources? I'm new to this so i'm having to start somewhere ha-ha.

The eventual aim is to construct an application that will allow users to enter the number of hours they have spent on a task(s) each day of the week.

Cheers for trying to help :D:D
 
Last edited:
I hadn't actually tried building the page because it was failing when I was testing the query, I understand what you mean now though.

Bare with me I am new :)

I'll give it a go and let you know. Thanks again.
 
Got it sorted now I was being silly, thanks :)

Well i'm always open to learning things different ways. I know you can just chuck on GridView components and pretty much configure them to do what you want really quickly, if that's what your talking about?

I'm guessing that tutorial is showing the way it SHOULD be done but not the easiest?

This is only for the sake of learning, i'm not actually developing the application I talked about yet because I don't have the know how lol :D
 
I'm not totally new to programming and do have some experience from college so it's not too bad. I was just getting confused about the right way to do it after reading a few tutorials and the set i've found and posted now seem to be the most comprehensive, so I decided to follow them.

Cheers for the help, no doubt expect more posts from me lol.

You a developer then by any chance?

I have to admit you could knock together applications pretty quickly compared to other languages if you knew what you were doing.
 
Back
Top Bottom