Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > q; merger two dataset

Reply
Thread Tools

q; merger two dataset

 
 
=?Utf-8?B?SklNLkgu?=
Guest
Posts: n/a
 
      05-22-2006
Hello,
Is it possible to merge two datasets which have three tables in each of
them? I am musing .Net 2.0 if this makes anything easier.
Any sample code will be greatly appreciated.
Thanks,

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TGFycnkgQ2hhcmx0b24=?=
Guest
Posts: n/a
 
      05-22-2006
The easy way is with the dataset designer. If you want to do it
programmatically, try:

Dim connString As String = My.Settings.ProjectConnection
Dim ds As New DataSet

Using cnn As New SqlClient.SqlConnection(connString)
cnn.Open()
Using cmd As New SqlClient.SqlCommand("mySP", cnn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@myParam", myValue)
Using da As New SqlClient.SqlDataAdapter(cmd)
da.TableMappings.Add("Table", "MyDatasetName1")
da.TableMappings.Add("Table1", "MyDatasetName2")
da.TableMappings.Add("Table2", "MyDatasetName3")
da.Fill(ds)
End Using
End Using
cnn.Close()
End Using

In the stored procedure just write some SQL
SELECT * FROM MyTableName1
SELECT * FROM MyTableName2
SELECT * FROM MyTableName3

It will work equally well with multiple dynamic SQL statements.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SklNLkgu?=
Guest
Posts: n/a
 
      05-22-2006
Hello Larry,
Thanks you very much for your reply. This fills the dataset, I need to merge
it with another dataset with the same schema, will that work with three
tables?


"Larry Charlton" wrote:

> The easy way is with the dataset designer. If you want to do it
> programmatically, try:
>
> Dim connString As String = My.Settings.ProjectConnection
> Dim ds As New DataSet
>
> Using cnn As New SqlClient.SqlConnection(connString)
> cnn.Open()
> Using cmd As New SqlClient.SqlCommand("mySP", cnn)
> cmd.CommandType = CommandType.StoredProcedure
> cmd.Parameters.AddWithValue("@myParam", myValue)
> Using da As New SqlClient.SqlDataAdapter(cmd)
> da.TableMappings.Add("Table", "MyDatasetName1")
> da.TableMappings.Add("Table1", "MyDatasetName2")
> da.TableMappings.Add("Table2", "MyDatasetName3")
> da.Fill(ds)
> End Using
> End Using
> cnn.Close()
> End Using
>
> In the stored procedure just write some SQL
> SELECT * FROM MyTableName1
> SELECT * FROM MyTableName2
> SELECT * FROM MyTableName3
>
> It will work equally well with multiple dynamic SQL statements.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question: merger dataset with three tables =?Utf-8?B?SklNLkgu?= ASP .Net 1 06-08-2006 01:55 AM
PDF Creater / Merger Jordan ASP .Net 2 08-07-2005 03:44 PM
Free PDF file merger? Murgi Computer Support 1 12-04-2004 03:09 PM
A merger in the making?? Vlad Digital Photography 1 02-21-2004 07:07 AM
Re: Log File Merger... °Mike° Computer Support 3 07-25-2003 10:34 AM



Advertisments