Solved

Fast Loading Of Typed DataSet ...

Posted on 2004-08-08
7
210 Views
Last Modified: 2010-04-23
hi..
i have a typed dataset that contains 15 tables as one object
or dataset.
i'm trying to fill the whole object at one time only,
i mean to do like :
DaSQL.Fill(Ds)
the way i'm doing is to do a loop for each table in my object
,get table name and Fill it
DaSQL.fill(Ds,TableName)
that means i'm going to the Db 15 times and thus making
slowness in loading the object.
the select sts are stored procedures for each table, those
contains alot of inner joins .

is there a way i can fill my dataset tables at one time,by going to the Db only once ..so it well be fast

How To Make DataSet Filling Fast other that taking out constraints and notifications...
0
Comment
Question by:star4
  • 3
  • 2
7 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11746953
Yes you can.

do something like

dim strsql as string = "select * from table1; select * from table2; select * from table3"  'etc ....
dim da as  new sqldataadapter(strsql,yourconnection)

you will have one small problem when using this method and that is the table names, ADO.net will name the tables
table, table1, table2 etc...

when you want to assign your one names, you have to use the tablemapping method of the dataadapter like

da.tablemappings.add('table", "yournamefortable1")
da.tablemappings.add('table1", "yournamefortable2")  'etc...


0
 

Author Comment

by:star4
ID: 11749726
dim strsql as string = "select * from table1; select * from table2; select * from table3"  'etc

this is fine , but i'm doing my Select Sts in Stored Procedures, its not like what you give
normal select , its complex ones that contains a lot of inner join , and i don't to put it in a string...
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11750642
Hi Star4,

You can't use multiple stored procedures in one dataadapter but you can have more then one select statement in single stored procedure. It works about the same way I described above. you can loop through the dataadapter with the .NextResult property.

look here also

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20995058.html
0
 

Author Comment

by:star4
ID: 11759476
this is nice and i try it .
but i'm getting an error saying "there is already a connection is opened"
can you give me an example ..
i'm using a typed dataset and i need to fill using DaSql.Fill + one time going to Db
for all tables. is this possible and how ?
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 125 total points
ID: 11760052
I tested this and this work just fine (dataset1 is the name of my typed dataset)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sqlStr As String = "workstation id=RB;packet size=4096;integrated security=SSPI;data source=RB;persist security info=False;initial catalog=mydatabase"
        Dim da As New SqlClient.SqlDataAdapter("newselectcommand", sqlStr)
        da.SelectCommand.CommandType = CommandType.StoredProcedure
        da.TableMappings.Add("Table", "contacten")
        da.TableMappings.Add("Table1", "contactpersonen")
        da.TableMappings.Add("Table2", "relaties")
        Dim ds As New Dataset1
        da.Fill(ds)

    End Sub

my stored procedure looks like this

ALTER PROCEDURE dbo.NewSelectCommand
AS
      SET NOCOUNT ON;
SELECT * FROM Contacten
Select * from contactpersonen where relatieid = 1
select * from relaties

You can also look here, it explains loading a typed dataset with a stored procedure that contains multiple resultsets

http://support.microsoft.com/default.aspx?scid=kb;en-us;322793
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question