?
Solved

Fast Loading Of Typed DataSet ...

Posted on 2004-08-08
7
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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