F
Francois Malgreve
Hi,
In a previous post I was asking how could I save (import) a large DataSet
(potentially 60.000 rows) into a SQL Server 2000 DB. It is a simple Data
transfer operation.
It seemed that the best way was to do it through a DTS.
I then started with a small DataSet that I saved into an Excel format. Then
I call the DTS that will import the excel file into the DataBase. This works
well.
But my problem is that the performance is VERY VERY low. It takes 30 seconds
to save a 250 rows Dataset into an excel sheet. Then my question is, does
anyone know how to save a DataSet in Excel in a better way? I will give a
code snippet .
Or should I save my DataSet into an other format and change my DTS? What
other format could I use?
Any help and clue would be very appreciated as I am kind of stuck here. I
did some research on the net, saw plenty of stuff to read from Excel but
much less to save on excel. Except something about Excel XML but it is not
an Excel file, just some XML format that Excel can understand.
Code snippet:
Basically to insert all fields from the dataSet into the Excel sheet, I just
loop through all rows, and for each rows loop through each columns. I then
insert manually the value from the DataSet into the Excel sheet. Well I can
guess that looping like that is unefficient but how else can I do?
''dsExcelExport is the dataSet
''Excel is the instance of excel.
For intRow = 0 To dsExcelExport.Tables(TableNo).Rows.Count - 1
For intColumnValue = 0 To dsExcelExport.Tables(TableNo).Columns.Count -
1
Excel.Cells(intRow + 2, intColumnValue + 1).Value =
dsExcelExport.Tables(TableNo).Rows(intRow).ItemArray(intColumnValue).ToStrin
g
Next
Next
Best regards,
Francois
In a previous post I was asking how could I save (import) a large DataSet
(potentially 60.000 rows) into a SQL Server 2000 DB. It is a simple Data
transfer operation.
It seemed that the best way was to do it through a DTS.
I then started with a small DataSet that I saved into an Excel format. Then
I call the DTS that will import the excel file into the DataBase. This works
well.
But my problem is that the performance is VERY VERY low. It takes 30 seconds
to save a 250 rows Dataset into an excel sheet. Then my question is, does
anyone know how to save a DataSet in Excel in a better way? I will give a
code snippet .
Or should I save my DataSet into an other format and change my DTS? What
other format could I use?
Any help and clue would be very appreciated as I am kind of stuck here. I
did some research on the net, saw plenty of stuff to read from Excel but
much less to save on excel. Except something about Excel XML but it is not
an Excel file, just some XML format that Excel can understand.
Code snippet:
Basically to insert all fields from the dataSet into the Excel sheet, I just
loop through all rows, and for each rows loop through each columns. I then
insert manually the value from the DataSet into the Excel sheet. Well I can
guess that looping like that is unefficient but how else can I do?
''dsExcelExport is the dataSet
''Excel is the instance of excel.
For intRow = 0 To dsExcelExport.Tables(TableNo).Rows.Count - 1
For intColumnValue = 0 To dsExcelExport.Tables(TableNo).Columns.Count -
1
Excel.Cells(intRow + 2, intColumnValue + 1).Value =
dsExcelExport.Tables(TableNo).Rows(intRow).ItemArray(intColumnValue).ToStrin
g
Next
Next
Best regards,
Francois