472,958 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

what is the problem with this?

m.a
Hello,

I am newbie and I am following this tutorial:

http://www.asp.net/learn/data-access...ial-01-cs.aspx

I am using MSVC 2008 and Access database.

I have my own database which is very similar to the database which is used
in this tutorial.

everything seems to be working till I am getting to step 3: Adding
Parameterized Methods to the Data Access Layer.

I cannot create an sql with parameterized data. my sql is as follow:

SELECT ID_Item, Title, [Desc], [image], User_ID
FROM Items
WHERE User_ID = @User_ID

but the system cannot detect that I used a parameter for where clause. it
complains that it can parse code after @ sign.

What is the problem and How can I fix it?

Best regards


Aug 1 '08 #1
1 994
On Aug 1, 12:28*pm, "m.a" <m...@spamoff.comwrote:
Hello,

* I am newbie and I am following this tutorial:

http://www.asp.net/learn/data-access...ial-01-cs.aspx

I am using MSVC 2008 and Access database.

I have my own database which is very similar to the database which is used
in this tutorial.

everything seems to be working till I am getting to step 3: Adding
Parameterized Methods to the Data Access Layer.

I cannot create an sql with parameterized data. my sql is as follow:

SELECT * * ID_Item, Title, [Desc], [image], User_ID
FROM * * * * Items
WHERE * * User_ID = @User_ID

but the system cannot detect that I used a parameter for where clause. it
complains that it can parse code after @ sign.

What is the problem and How can I fix it?

Best regards
You need code to tell it what to replace the parameter with. For
example in C#:
SqlConnection con = GetConnection();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandTimeout = 500;
cmd.CommandText = "SELECT something FROM somewhere WHERE something =
@yourParam";
cmd.CommandText = cmd.CommandText.Replace("@yourParam", actualValue);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);

Aug 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Henley | last post by:
I first came across rebol a while ago; it seemed interesting but then i was put off by its proprietary nature, although the core of the language is a free download. Recently however, i can't...
8
by: Randell D. | last post by:
I have just recompiled, upgraded to PHP 4.3.4. As an exercise (and curiosity) I've decided to test out PDF functions and got the test in the PHP online manual working. I had one problem whereby...
2
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
11
by: Leo | last post by:
hi there for somebody who wants tostart small/medium GUI apps with python: what's the best toolkit: tkinter, wxPython or what? stability, ease of use and portability between mac and windows...
3
by: Kenneth McDonald | last post by:
One of my current "fun" goals is to start playing with 3D related things, purely because I find it of interest. Since I also use and love Python in more serious endeavours, it would seem to make...
9
by: Martin Maney | last post by:
In my copious spare time I've been dabbling at getting a computerized version of a board game working. After deciding that tk just made me want to vomit, and wx was like swimming through...
3
by: Ron_Adam | last post by:
Ok... it's works! :) So what do you think? Look at the last stacked example, it process the preprocess's first in forward order, then does the postprocess's in reverse order. Which might be...
30
by: James Conrad StJohn Foreman | last post by:
After 3 years of using DB2 on Linux, I'm leaving my current employers to go work for a SQL Server shop instead. In order to find my replacement, they're trying to put together a set of questions...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.