Solved

Fast Loading Of Typed DataSet ...

Posted on 2004-08-08
7
213 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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