Solved

Fast Loading Of Typed DataSet ...

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now