|
-
Jul 17th, 2007, 02:22 AM
#1
Frenzied Member
Re: [2005] Fill a dataset with 2 unrelated Tables.
Hello,
Just looking at your code, but could you not use just 1 adatper
i.e.
vb Code:
Dim da As New System.Data.SqlClient.SqlDataAdapter()
Dim cmd As New System.Data.SqlClient.SqlCommand()
Dim ds As DataSet
cmd.CommandText = "Select * From Table1"
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "Table1")
cmd.CommandText = "Select * From Table2"
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "Table2")
-
Jul 17th, 2007, 02:24 AM
#2
Re: [2005] Fill a dataset with 2 unrelated Tables.
 Originally Posted by steve_rm
Hello,
Just looking at your code, but could you not use just 1 adatper
i.e.
vb Code:
Dim da As New System.Data.SqlClient.SqlDataAdapter()
Dim cmd As New System.Data.SqlClient.SqlCommand()
Dim ds As DataSet
cmd.CommandText = "Select * From Table1"
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "Table1")
cmd.CommandText = "Select * From Table2"
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "Table2")
You could but you wouldn't. If you are using DataAdapters then that would imply that you would need to Update the data too. If you didn't need to update the data then you should use a DataReader to load the data, in which case you could use the same Command with different CommandText each time.
-
Jul 17th, 2007, 10:43 AM
#3
Thread Starter
Member
Re: [2005] Fill a dataset with 2 unrelated Tables.
Didnt figure that. I am going to need to update both tables.
Tx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|