473,439 Members | 1,725 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,439 software developers and data experts.

Passing multiple Ids into one query parameter

Hi everyone

I am writting an application in VB.NET to print orders. The orders are shown on screen in a listview and the user can select individual orders/range of orders to print.

This Access query looks like:

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS OrderIds Text ( 255 );
  2. SELECT orders.*, orderdetails.*
  3. FROM orders, orderdetails
  4. WHERE orders.orderid=orderdetails.orderid And orders.orderid IN (OrderIds);
How do I from vb.net pass the OrderIds parameter into this query with multiple orderids?

e.g. passing "123-456" works
passing " '123-456', '123-789' " doesn't.

Thanks

Darren
Aug 30 '07 #1
7 5425
puppydogbuddy
1,923 Expert 1GB
Hi everyone

I am writting an application in VB.NET to print orders. The orders are shown on screen in a listview and the user can select individual orders/range of orders to print.

This Access query looks like:

Expand|Select|Wrap|Line Numbers
  1. PARAMETERS OrderIds Text ( 255 );
  2. SELECT orders.*, orderdetails.*
  3. FROM orders, orderdetails
  4. WHERE orders.orderid=orderdetails.orderid And orders.orderid IN (OrderIds);
How do I from vb.net pass the OrderIds parameter into this query with multiple orderids?

e.g. passing "123-456" works
passing " '123-456', '123-789' " doesn't.

Thanks

Darren
Try the following sql wildcard search syntax from the tips page of www.aadconsulting.com:

Access SQL Tip

Search for two or more single characters in a field. You can use the [ ] wildcard with the Like operator in your queries to search for two or more single characters in a field.

For example, suppose you want to find all customers with the following ZIP codes: 08052, 08053, or 08055. To use the [ ] wildcard, enter the following in your query's Criteria row under the ZIP Code field:

Like "0805[235]"

This expression searches for all field entries whose last character matches one of the characters specified between the brackets. Conversely, to search for all customers that don't live within these three ZIP code areas, place an exclamation point before the list, as shown below:

Like "0805[!235]"

The exclamation point inside the brackets stands for Not in the list. The query results will include all entries whose characters do not match any character in the list within the brackets.

You can combine the [ ] wildcard with any other wildcard character. For example, you can combine the * wildcard character with [ ] to search for any ZIP codes that begin with 0805, 0807, or 0808:

Like "080[578]*"
Aug 30 '07 #2
Thanks for the reply, thats good stuff.

Unfortunately the orderids are completely random

026-0159838-5236468
026-0306078-8746874
026-1029245-0735648
026-1790187-0193253
026-1819529-7034066
026-1867624-0583628
026-2072900-6146861
026-3218124-3627631
026-3633922-3964433
026-4139046-7462031
026-5450239-6649260
026-5697553-7696467
026-6255318-3013260
026-7330560-6660409
026-7416110-2947619
026-7981809-9406852
026-8970197-8098839
026-9026164-8467661
026-9184117-1284430
202-2567116-6704600
202-4304970-2084604
202-4967319-2839036
202-5926126-1864637
202-6029787-0011009
202-8072221-5702232
202-8229158-1799057
202-8552470-9176645
202-8877723-7834239
202-8909546-2755045
202-9876626-3265466
203-2199425-8072703
203-2374079-0492742
203-5221247-2952723
203-6471040-6710305

If these were showing on the listview the user can pick one or many and i need the values to be passed into the query so my crystal report is returned all the information it needs to produce the report.

Darren
Aug 30 '07 #3
puppydogbuddy
1,923 Expert 1GB
<<<<<e.g. passing "123-456" works
passing " '123-456', '123-789' " doesn't.>>>>

Try this:

"123-456,123-789"
Aug 30 '07 #4
HI

Nope that doesnt work either as it thinks the whole string including the comma is what im looking for in OrderId.

Thanks
Aug 31 '07 #5
Jim Doherty
897 Expert 512MB
HI

Nope that doesnt work either as it thinks the whole string including the comma is what im looking for in OrderId.

Thanks

Just a thought...Can I suggest an alternative method to you and that is because you may or may not face a total string length limitation with the IN (I see your orderids are pretty length?) whereas using a JOIN in SQL you will not. If you were to create a one column holding table and pump in those orderid values into it you could LEFT join on the order ids where holdingtable.orderid=order.id
you could truncate or should I say delete from the holding table each time the call is made to the dataset return?

Jim
Aug 31 '07 #6
puppydogbuddy
1,923 Expert 1GB
HI

Nope that doesnt work either as it thinks the whole string including the comma is what im looking for in OrderId.

Thanks

Ok, here you go. See this link from Microsoft, providing 2 ways to enter multiple values for a parameter. I think the second method, which use a function (the code is provided) is the way to go.

http://support.microsoft.com/kb/210530
Aug 31 '07 #7
Thanks puppydogbuddy

Ill have a look at that when I get a minute.

You are right with the limit. The limit i was finding was 225. If they selected more than that from the list I simply said remove some orders or print one a t a time which will take a lot longer.

Luckily they seem to be printing off 100 at a time so havent seen this restriction yet !!

This is what made me start to look at alternatives methods.

Thanks
Sep 4 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: bpschmid | last post by:
Ive got a datagrid with a hyperlink column. I want to click on that column and go to another page, but here's the kicker, I need and want to pass not one, but two different query string parameters...
2
by: The Plankmeister | last post by:
Hi... I have a query which I'm accessing through PHP as a stored procedure. However, I need to be able not to pass a couple of parameters in certain situations. When I do this, I get an error: ...
3
by: cassandra.flowers | last post by:
Hi, I was wondering if it is possible (Using access) to have a query parameter as a drop down box rather than a text box? e.g. typing as criteria for a query produces a box with a text box...
2
by: Paul Hale | last post by:
Hi all, being new to c# I'm trying to find the best way of passing multiple records to insert into a sql database via a stored procedure. I'm using visual studio 2005 RC SQL server 2005 and C# of...
3
by: Uwe | last post by:
Howdy! I've googled and googled for this without success, and either it's so easy that nobody has ever asked, or there is some serious reason nobody would do this. But I'm going to ask anyway....
1
by: Roy | last post by:
I'm assuming this is amazingly simple and I'm just missing the boat. On the html side of an asp.net page I have a datagrid, a "search" button, and 8 text boxes for search criteria. A user enters...
4
by: Nathan Sokalski | last post by:
I am a beginner with AJAX, and have managed to learn how to use it when passing single parameters, but I want to return more than one value to the client-side JavaScript function that displays it....
1
by: Néstor Sánchez A. | last post by:
Hi, is there a way, maybe using reflection, to use a generic class passing the type parameter dynamicly (not kwnowing the exact type at compile time)? I tried the next example, but doesn't work: ...
2
ntxsoft
by: ntxsoft | last post by:
Hello everybody, I have a problem while I am trying to execute multiple query in a statement. My query like that DROP TABLE IF EXISTS query; CREATE TEMPORARY TABLE query SELECT...
11
by: Whizzo | last post by:
Hi all; Well, I've had my obligatory hour of Googling, scratching my head and trial and error and now I'm stumped. I'm using the following code as a query parameter: ALike...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.