Ask a Question related to ASP.NET General, Design and Development.
-
Jake #1
Updateing a database table from a dataset
Hi all,
I am trying to update an SQL server table from a dataset
populated by an excel spread sheet. Each record has a
check box so it can be excluded from the SQL server table
population.
Does anyone now how I would acheive this, I don't want to
have to loop through each record in the dataset and do a
separate insert for each record as there can be allot of
records, and this would result in a waste for recourses.
I was hoping the dataset might have a method that can
perform a bulk insert.
Thanks in advance.
Jake
Jake Guest
-
How many dataBase tables can a dataSet table update via dataGrid?
I would like to display data in a datagrid in which the source of the data is multiple database tables. The select statement in the command object... -
how to set visible table out of dataset?
Hi, all. A Form has a DataGrid bound to a DataSet including two DataTable, A and B. When Form is loaded the two table is populated to DataSet and... -
Dataset to table
Hi I have a dataset which is filled with data. How can I write this dataset into a local access table and also creating the table if it does not... -
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset
Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data... -
Dataset and table names.....
I have a stored procedure that queries a sql server database and returns the multiple data tables ( 7 to be precise) these tables are the results of... -
Steve Letford #2
Re: Updateing a database table from a dataset
You can do bulk updating using a dataadapter. However because you are
retrieving data from the excel sheet and updating another datasource then
you probably can't do that.
Also, the dataadapter would do an inefficient update as it tends to do more
joins than it needs to. You are probably better off and more efficient to
loop through each record using a datareader and doing the update. I think!
Steve
"Jake" <reachJake@hotmail.com> wrote in message
news:14c001c35bc1$c1817b50$7d02280a@phx.gbl...> Hi all,
> I am trying to update an SQL server table from a dataset
> populated by an excel spread sheet. Each record has a
> check box so it can be excluded from the SQL server table
> population.
>
> Does anyone now how I would acheive this, I don't want to
> have to loop through each record in the dataset and do a
> separate insert for each record as there can be allot of
> records, and this would result in a waste for recourses.
> I was hoping the dataset might have a method that can
> perform a bulk insert.
>
> Thanks in advance.
>
> Jake
Steve Letford Guest
-
Jake #3
Re: Updateing a database table from a dataset
Hi steve,
Thanks for the feed back. I just seems there must be a
more efficient way considering if there is 10000 records
to be inserted ASP.Net has to continuously connect to the
DB 10,000 times. I have tried and it takes 30 seconds to
run, which is not too bad. I was hoping that there was
some sort of bulk insert?
Cheers Jake.
because you are>-----Original Message-----
>You can do bulk updating using a dataadapter. Howeveranother datasource then>retrieving data from the excel sheet and updatingit tends to do more>you probably can't do that.
>
>Also, the dataadapter would do an inefficient update asmore efficient to>joins than it needs to. You are probably better off andthe update. I think!>loop through each record using a datareader and doingdataset>
>Steve
>
>"Jake" <reachJake@hotmail.com> wrote in message
>news:14c001c35bc1$c1817b50$7d02280a@phx.gbl...>> Hi all,
>> I am trying to update an SQL server table from atable>> populated by an excel spread sheet. Each record has a
>> check box so it can be excluded from the SQL serverto>> population.
>>
>> Does anyone now how I would acheive this, I don't wanta>> have to loop through each record in the dataset and doof>> separate insert for each record as there can be allotrecourses.>> records, and this would result in a waste for>>> I was hoping the dataset might have a method that can
>> perform a bulk insert.
>>
>> Thanks in advance.
>>
>> Jake
>
>.
>Jake Guest
-
Natty Gur #4
Re: Updateing a database table from a dataset
Hi,
You can use Bulk insert with command object.
Sql = "insert into a values('0');insert into a values('1')";
SqlCommand oCmd = new SqlCommand(Sql,oConnection);
int i = oCmd.ExcecudeNonQuery();
Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Natty Gur Guest
-
Steve Letford #5
Re: Updateing a database table from a dataset
Not as far as I'm aware. I think I'm correct in saying that even the
dataadapter, which gives the impression of a bulk insert is using a
datareader behind the scenes to do the insert.
As the data adapter doesn't know the datamodel, it has a rough guess on the
number of joins that it needs to do and therefore could be wrong as it may
join a number of different fields instead of perhaps just one that it needs.
Its been a while since I read all this but I'm pretty sure that I'm right.
I still think you'll need to loop through each record and do the insert, at
least that way you can put the inserts into a transaction.
Hope this helps.
Steve
"Jake" <reachJake@hotmail.com> wrote in message
news:085201c35bd5$ab68ce40$a301280a@phx.gbl...> Hi steve,
>
> Thanks for the feed back. I just seems there must be a
> more efficient way considering if there is 10000 records
> to be inserted ASP.Net has to continuously connect to the
> DB 10,000 times. I have tried and it takes 30 seconds to
> run, which is not too bad. I was hoping that there was
> some sort of bulk insert?
>
> Cheers Jake.
>
>> because you are> >-----Original Message-----
> >You can do bulk updating using a dataadapter. However> another datasource then> >retrieving data from the excel sheet and updating> it tends to do more> >you probably can't do that.
> >
> >Also, the dataadapter would do an inefficient update as> more efficient to> >joins than it needs to. You are probably better off and> the update. I think!> >loop through each record using a datareader and doing> dataset> >
> >Steve
> >
> >"Jake" <reachJake@hotmail.com> wrote in message
> >news:14c001c35bc1$c1817b50$7d02280a@phx.gbl...> >> Hi all,
> >> I am trying to update an SQL server table from a> table> >> populated by an excel spread sheet. Each record has a
> >> check box so it can be excluded from the SQL server> to> >> population.
> >>
> >> Does anyone now how I would acheive this, I don't want> a> >> have to loop through each record in the dataset and do> of> >> separate insert for each record as there can be allot> recourses.> >> records, and this would result in a waste for> >> >> I was hoping the dataset might have a method that can
> >> perform a bulk insert.
> >>
> >> Thanks in advance.
> >>
> >> Jake
> >
> >.
> >
Steve Letford Guest
-
Steve Letford #6
Re: Updateing a database table from a dataset
you'd still have to loop through each record and build up a huge sql
statment that would do the insert.
There are 2 problems with doing it this way, in my opinion:
1. The final sql statement would be huge for 1000 records. There might
even be problems trying execute a massive sql statement on the database.
2. I don't think you should do native sql statements on a database that is
allowing user input because you open yourself up to sql injection issues.
Therefore you'd have to parse each insert statement.
So, still reckon youre better off doing it the long way. Which, wouldn't
take too long anyway. The connection would only be open once while you loop
through the records and most of the time is taken up establishing the
connection.
Steve
"Natty Gur" <natty@dao2com.com> wrote in message
news:eD6Uzl9WDHA.2064@TK2MSFTNGP11.phx.gbl...> Hi,
>
> You can use Bulk insert with command object.
>
> Sql = "insert into a values('0');insert into a values('1')";
> SqlCommand oCmd = new SqlCommand(Sql,oConnection);
> int i = oCmd.ExcecudeNonQuery();
>
> Natty Gur, CTO
> Dao2Com Ltd.
> 34th Elkalay st. Raanana
> Israel , 43000
> Phone Numbers:
> Office: +972-(0)9-7740261
> Fax: +972-(0)9-7740261
> Mobile: +972-(0)58-888377
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Steve Letford Guest
-
Natty Gur #7
Re: Updateing a database table from a dataset
Steve,
You absolute right but it still more efficient to reduce calls the DB.
You have to go through the records one way or another at lest you can
reduce calling DB from 1000 times to 100 times. Check for RPC and see it
for yourself.
I’m not SQL server expert but I know that oracle can execute bulk insert
parallel, if its holds true for SQL server this can also help your
performance.
Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Natty Gur Guest
-
Steve Letford #8
Re: Updateing a database table from a dataset
There you go Jake, 2 possible well reasoned methods.
Take your pick.
Thanks Natty
Steve
"Natty Gur" <natty@dao2com.com> wrote in message
news:OJl$w2IXDHA.1204@TK2MSFTNGP12.phx.gbl...> Steve,
>
> You absolute right but it still more efficient to reduce calls the DB.
> You have to go through the records one way or another at lest you can
> reduce calling DB from 1000 times to 100 times. Check for RPC and see it
> for yourself.
>
> I'm not SQL server expert but I know that oracle can execute bulk insert
> parallel, if its holds true for SQL server this can also help your
> performance.
>
> Natty Gur, CTO
> Dao2Com Ltd.
> 34th Elkalay st. Raanana
> Israel , 43000
> Phone Numbers:
> Office: +972-(0)9-7740261
> Fax: +972-(0)9-7740261
> Mobile: +972-(0)58-888377
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Steve Letford Guest



Reply With Quote

