473,403 Members | 2,359 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,403 software developers and data experts.

How to Query Database by applying where condition from another recordset.

Hi,

I have a table IV00108wc which contains several thousand records in whcih
ITEMNMBR is the primary key.

I have a com+ object returning recordset which has ITEMNMBR and another
details related. [I do not have direct query to get the list]

I want to query another table based on Com+ object recordset.
Select distinct WebClas1 from IV00108wc where ItemNmbr in (...).
where, I want the ItemNmbr list from the COM+ recordset.

Please suggest me how to do the query and apply the where condition from the
resulted recordset ?

Regards,

Sreedhar Vankayala
Nov 15 '05 #1
2 1674
Hi Sreedhar,

Can't you call scroll through the com+ recordset and build a global,
concatenated string containing all itemnmbr's brackets with chr(39), such as
this:

(if .net)
for each irow in rs.tables(0).rows
bulkstring = bulkstring & chr(39) & irow("itemnmbr") & chr(39)
next

Then concatenate the query.

If you are using sql server, you could also create a table using 'insert
into...from' etc inside the com+ object; then use that table to build
bulkstring as indicated above.

HTH,

Bernie Yaeger

"Sreedhar Vankayala" <v_********@hotmail.com> wrote in message
news:uo*************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a table IV00108wc which contains several thousand records in whcih
ITEMNMBR is the primary key.

I have a com+ object returning recordset which has ITEMNMBR and another
details related. [I do not have direct query to get the list]

I want to query another table based on Com+ object recordset.
Select distinct WebClas1 from IV00108wc where ItemNmbr in (...).
where, I want the ItemNmbr list from the COM+ recordset.

Please suggest me how to do the query and apply the where condition from the resulted recordset ?

Regards,

Sreedhar Vankayala

Nov 15 '05 #2
1. Create a comma separated string from COM+ recordset
2. Pass the generated string to Select method on the table IV00108wc,
as Select("ItemNumber IN( 100,300,450) " ) ;
sample code for the part 2 :
-----------------------------------
using System ;
using System.Data ;

class AB
{
public static void Main()
{
DataTable dt ;
DataRow dr ;
DataRow[] arDataRow ;
dt = new DataTable() ;
dt.Columns.Add ( "ItemNumber", typeof(int)) ;
dt.Columns.Add ( "ItemDescription", typeof( string )) ;
dr = dt.NewRow() ; dr[0] = 100 ; dr[1] = "AAAAA" ; dt.Rows.Add ( dr )
;
dr = dt.NewRow() ; dr[0] = 200 ; dr[1] = "BBBBB" ; dt.Rows.Add ( dr )
;
dr = dt.NewRow() ; dr[0] = 300 ; dr[1] = "CCCCC" ; dt.Rows.Add ( dr )
;
dr = dt.NewRow() ; dr[0] = 400 ; dr[1] = "DDDDD" ; dt.Rows.Add ( dr )
;
dr = dt.NewRow() ; dr[0] = 450 ; dr[1] = "DDDDD" ; dt.Rows.Add ( dr )
;
dr = dt.NewRow() ; dr[0] = 500 ; dr[1] = "DDDDD" ; dt.Rows.Add ( dr )
;

arDataRow = dt.Select("ItemNumber IN( 100,300,450) " ) ;
Console.WriteLine ( arDataRow.Length ) ;
}
}

-----------------------------------
"Sreedhar Vankayala" <v_********@hotmail.com> wrote in message news:<uo*************@TK2MSFTNGP10.phx.gbl>...
Hi,

I have a table IV00108wc which contains several thousand records in whcih
ITEMNMBR is the primary key.

I have a com+ object returning recordset which has ITEMNMBR and another
details related. [I do not have direct query to get the list]

I want to query another table based on Com+ object recordset.
Select distinct WebClas1 from IV00108wc where ItemNmbr in (...).
where, I want the ItemNmbr list from the COM+ recordset.

Please suggest me how to do the query and apply the where condition from the
resulted recordset ?

Regards,

Sreedhar Vankayala

Nov 15 '05 #3

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

Similar topics

14
by: David Lozzi | last post by:
OK, I know how to use to pull up all records that contains the keyword, but what about not containing the keyword? I've tried NOT LIKE but i get Arguments are of the wrong type, are out of...
20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
9
by: shank | last post by:
Per a previous suggestion, I'm trying to use a parametized query in Access 2002. The query functions properly in Access. Now I'm trying to call it from ASP. I'm using code I found at...
8
by: Dave | last post by:
Hi all, I've been trying to figure this out for the last day and a half and it has me stumped. I've got a web application that I wrote that keeps track of trading cards I own, and I'm moving it...
2
by: JMCN | last post by:
hi i have a general question regarding append queries in access 97. each week i need to update my table(tblonlinereg) with new or modified records. firstly, i import the text file into my...
19
by: bdt513 | last post by:
I am trying to extract the values from a query using VBA. Specifically, I want to concatenate all the values of the "rosEmail" field from query "qselRosterEmailList" into one string (strEmails). I...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
1
by: Intrepid_Yellow | last post by:
Hi, I have the following code that runs my report generator. The user selects a table from a combo box, then whatever fields they want from a list box. (This part all works and the report runs...
6
by: Nano | last post by:
I want to update a MS Access Table using ASP, I have made the connection with the database but I am unable to update it. I am using the following code: ...
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
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...

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.