SQL Helper Class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I'm using Microsoft Application Blocks in a project I'm working on.
I now need to populate a single dataset, that consists of 2 tables.
From what I've read, if I wasn't using MS Application Blocks, it would
simply be

dataAdapter1.fill(dataset1("table1")
dataAdapter1.newSelectCommandHere
dataAdapter1.fill(dataset1("table2")

Am I able to do this with the SQLHelper Class in MS App. Blocks?
I don't seem to be able to specify which table to load the data into...

This is my line of code:

Dim tables(1) As String
tables(0) = "table1"
tables(1) = "table2"

SqlHelper.FillDataset(SqlDbManager.GetConnectionString,
CommandType.StoredProcedure, _
"Milestones_Read", ds, tables, sqlPararameter1)

Thanks!,
Amber
 
Amber,

You can populate a dataset with multiple tables in a single trip.
Get your stored proceedure to do the 2 selects required
CREATE PROCEDURE Milestone_Read
AS
SELECT * FROM table1;
SELECT * FROM table2;

OR
Write a new proceedure to call the original 2 stored proceedures
CREATE PROCEDURE All_Milestone_Read
(

AS
EXEC SP1
EXEC SP2

Now just call your existing code with small mods to param 5 and 6.

SqlHelper.FillDataset(SqlDbManager.GetConnectionString,
CommandType.StoredProcedure, _
"Milestones_Read", _
ds, _
new string() {"Table1","Table2"}, _ ' this names the tables
New SqlParameter() {("@Table1P1, p1"),("@Table2P1,p2"}) '
this passes any parameters


Oh ds.Table(0) is the result of the first select and ds.Table(1) is the
result of the second select and so on.
So you do need to know the order in which the sproc made the selects.

I have not actually compiled and tested this but it cant be far off.

Luck Chris
 
Back
Top