Using datatable as subquery in sql query

Posted by Thiru under Sql Server on 3/27/2012 | Points: 10 | Views : 6002 | Status : [Member] | Replies : 4
Hi,
Is it possible to use dataset.datatable records as subquery in a main sql query.

example:

Assume Dataset.Datatable having 20 records in two fields (AgentCode and AgentName)
and in database there is a table named tblagent.

Now i like to get result like:

Select AgentCode, AgentName From tblAgent where AgentCode in (Select that dataset.datatable.col("AgentCode") )


Is it possible in Vb.Net - if so, how to do.

Expecting your valuable reply.
Regards,
Thiru.




Responses

Posted by: Balajikcp8 on: 3/27/2012 [Member] Starter | Points: 25

Up
0
Down
I think, you have to try with "LINQ"

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/27/2012 [Member] Bronze | Points: 25

Up
0
Down
yes you can do it, by creating dataview and filter your query in dataset. it is possible.

Thanks,
Rajni Shekhar

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/27/2012 [Member] Bronze | Points: 25

Up
0
Down
Yes


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 4/5/2012 [Member] Starter | Points: 25

Up
0
Down
Really,
if possible can you give an example/sample.

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response