473,465 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to use IN () syntax in asp.net datasets (xsd)

3 New Member
Hi,

I use Visual studio datasets to create table adapters etc. for queries. This normally works fine for me with 'simple' queries (i.e. only 1 parameter of type string, int ...). However if I specify the following query in the dataset:

SELECT * from tblTable WHERE tblId IN (@idList)

the query editor accepts, but the generated code will create a function that just accepts a single integer. Changing the type of idList to string and passing in a string in the form of "1,2,3" also doesn't work.

Is it at all possible to use the IN keyword in queries using the datasets, and if so, what is the way to do this?

Thanks very much in advance!

Arthur
Sep 21 '09 #1
6 2024
MrMancunian
569 Recognized Expert Contributor
Hi Arthur,

I'm not quite sure what you're trying to accomplish with your query, but it sounds to me like you can use a subquery. Can you explain what format your table has and what output do you expect?

Steven
Sep 21 '09 #2
arthurvanderwal
3 New Member
Hi Steven,

I like to retrieve records of which the ID is one of the IDs i supply..

so

SELECT * FROM tblTable WHERE id IN (1,2,3,4,5)

would be the thing I'm after...

However if I try this with

SELECT * FROM tblTable WHERE id IN (@idList)

I don't get it to work ...

Thanks!

Arthur
Sep 21 '09 #3
ssnaik84
149 New Member
check these methods -

DataView.RowFilter

DataTable.Select
Sep 21 '09 #4
arthurvanderwal
3 New Member
Thanks ssnaik84!

However I cant help but thinking that these functions do a 'non' MSSQL operation on the dataset. Ie aren't these functions potentially slow on large result sets?
Sep 22 '09 #5
ssnaik84
149 New Member
ok.. you need MSSQL function then..

Expand|Select|Wrap|Line Numbers
  1. CREATE FUNCTION [dbo].[GetTableFromCSV] ( @StringInput VARCHAR(100) )
  2. RETURNS @OutputTable TABLE ( [id] int identity(1,1), [String] NVARCHAR(4000) )
  3. AS
  4. BEGIN
  5.  
  6.     DECLARE @String    VARCHAR(10)
  7.  
  8.     WHILE LEN(@StringInput) > 0
  9.     BEGIN
  10.         SET @String      = LEFT(@StringInput, 
  11.                                 ISNULL(NULLIF(CHARINDEX(',', @StringInput) - 1, -1),
  12.                                 LEN(@StringInput)))
  13.         SET @StringInput = SUBSTRING(@StringInput,
  14.                                      ISNULL(NULLIF(CHARINDEX(',', @StringInput), 0),
  15.                                      LEN(@StringInput)) + 1, LEN(@StringInput))
  16.  
  17.         INSERT INTO @OutputTable ( [String] )
  18.         VALUES ( @String )
  19.     END
  20.  
  21.     RETURN
  22. END
to run it..

Expand|Select|Wrap|Line Numbers
  1. select * from dbo.GetTableFromCSV('1,2,3')
Sep 22 '09 #6
ssnaik84
149 New Member
@arthurvanderwal

Expand|Select|Wrap|Line Numbers
  1. SELECT * from tblTable WHERE tblId IN (
  2. select id from dbo.GetTableFromCSV('1,2,3')
  3. )
  4.  
Sep 22 '09 #7

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

Similar topics

7
by: Tim Smith | last post by:
Hi, Is it possible to create a progam to mimic the following action a) drag oledbadapter to form1.cs b) select my oracle ole connection c) enter 'select * from mytable' d) create adapter for...
4
by: Alpha | last post by:
I have a small Window application and through out the different forms I create a different dataset. At the begining I used the Tools to drag and drop the SqlDataAdapter, connection and dataset...
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
4
by: S Chapman | last post by:
Is there any tool that generates Typed DataTables rather than Typed Datasets? The trouble we are having is we have quite a few tables in our database and a single table can be a part of more than...
3
by: Mike | last post by:
Hi, I'm delevloping a webservice that returns typed datasets with visual studio 2005. The problem is, that the typed data set in the client app is not the same as in the webservice. If I change...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
4
by: Peter | last post by:
Hi! I am frustrated! I spent a lot of time designing a custom dataset schema (XSD file) using the Dataset designer. In my main form I had created an instance of a typed dataset using that...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
6
by: Bobby Edward | last post by:
Using ASP.NET 3.5 and MySQL (thru DevArt MyDirect.NET)... On the production server I get a "Parser Error" for every XSD dataset. It works perfect on my dev machine. But, on the production...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
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
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: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.