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
Solved

Fast Loading Of Typed DataSet ...

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

837 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