473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Using Access queries via asp.net

Hi i've got an application in dotnet that uses
queries from an Access database.
Now most of the common select statements return the desired data,
however, one the queries requires a parameter.
This particular queries does not return the correct data.
I've tested the query in access and it works.

Somehow the parameter that I pass from asp.net does not seem
to be arriving.
This is a sample query of how it looks:
PARAMETER xParam Text(30)
Select * from Table
WHERE param LIKE xparam
xparam contains a *-wildcard at the beginning and end of the string.

And this is how I summon the query
DataSet result = new DataSet();
string searchstring = "*DA*";
OleDbCommand sqlCommand = new OleDbCommand();
sqlCommand = new OleDbCommand("NAME_OF THE
QUERY",(OleDbConnection)conn.Connectie,(OleDbTrans action)conn.Transactie);
sqlCommand.Parameters.Add(new OleDbParameter("xParam", OleDbType.Char,
30));
sqlCommand.Parameters["xParam"].Value = searchstring;
sqlCommand.CommandType = CommandType.StoredProcedure;
this.oleDbDataAdapter1.SelectCommand = sqlCommand;
oleDbDataAdapter1.Fill(result);

I use this way to access other selectqueries that do not use
parameters
and these work just fine. Just the ones with parameters don't work.
Can you help me fix this?

Kind Regards
Dirk Vervecken
di************@vgc.be
Tel: +32 (0)2/208 02 05
-----
Directie Financiën en Algemene Zaken
Informatica
-----
Vlaamse Gemeenschapscommissie
SaincteletteSquare 17
1000 Brussel
www.digitaalbrussel.be
-----
Nov 18 '05 #1
2 1323
The * works inside Access.
But in OLEDB code you need to use the % sign.
--
Joe Fallon


"Dirk Vervecken" <Di************@vgc.be> wrote in message
news:6c**************************@posting.google.c om...
Hi i've got an application in dotnet that uses
queries from an Access database.
Now most of the common select statements return the desired data,
however, one the queries requires a parameter.
This particular queries does not return the correct data.
I've tested the query in access and it works.

Somehow the parameter that I pass from asp.net does not seem
to be arriving.
This is a sample query of how it looks:
PARAMETER xParam Text(30)
Select * from Table
WHERE param LIKE xparam
xparam contains a *-wildcard at the beginning and end of the string.

And this is how I summon the query
DataSet result = new DataSet();
string searchstring = "*DA*";
OleDbCommand sqlCommand = new OleDbCommand();
sqlCommand = new OleDbCommand("NAME_OF THE
QUERY",(OleDbConnection)conn.Connectie,(OleDbTrans action)conn.Transactie);
sqlCommand.Parameters.Add(new OleDbParameter("xParam", OleDbType.Char,
30));
sqlCommand.Parameters["xParam"].Value = searchstring;
sqlCommand.CommandType = CommandType.StoredProcedure;
this.oleDbDataAdapter1.SelectCommand = sqlCommand;
oleDbDataAdapter1.Fill(result);

I use this way to access other selectqueries that do not use
parameters
and these work just fine. Just the ones with parameters don't work.
Can you help me fix this?

Kind Regards
Dirk Vervecken
di************@vgc.be
Tel: +32 (0)2/208 02 05
-----
Directie Financiën en Algemene Zaken
Informatica
-----
Vlaamse Gemeenschapscommissie
SaincteletteSquare 17
1000 Brussel
www.digitaalbrussel.be
-----

Nov 18 '05 #2
I've tried that. I've placed *'s directly in the access query. No
succes. It simply seems as though the info
in the parameter is not passed from the .net application
to Access.
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

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

Similar topics

25
by: cory | last post by:
Hi, I have an Access database and am having an ASP.NEt application written for it. It is almost complete. I have a hosting company that I signed up with a month ago but before I did anything I...
1
by: Steve | last post by:
I am using Access 2000 and I have a DB that is currently running four different queries from some Forms and subforms. These queries each have a date field that are seperate from each other that are...
1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
11
by: maryjones11289 | last post by:
Hi, I have an app (lost the source code) that performs many different queries in order to achieve the results I'm looking for. Re-developing the app isn't really a big issue...but what would be...
6
by: Serious_Practitioner | last post by:
Good day all, and thank you in advance for your help. No - MANY thanks in advance for your help - I know nothing about using databases on Web servers. I am about to discuss a project with a...
1
by: JH | last post by:
I have a comma delimited file and I want to export it to an MS access table already designed with appropriate field names. How do I do this programmatically using VB.NET or C#? Thanks for any...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
3
by: AP | last post by:
Hello I have a department full of Access databases. I am starting to think about moving some of the larger ones to use a sql server backend. I do not want to go throught the technical upsizing. I...
1
by: kkrizl | last post by:
I've tried to research this problem, and I haven't been able to find any references to it. Probably because I shouldn't be doing it, but it was working, and now it's not. I'm trying to develop a...
0
MMcCarthy
by: MMcCarthy | last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access. Angle brackets <> are used in place of some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.