473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Reading multiple excel file into 1 dataset.

Hi, Good Day!

Reading 1 excel file into a dataset is fine.
How can I read multiple excel with the same data structure into 1 dataset?
How can I append those data?

Can someone help?
Thanks in advanced.

rgds,
Phoebe.
Nov 20 '05 #1
4 5175
Cor
Hi Phoepe,

I never did it or try it, but try to fill it in a dataset, than it should go
like this

\\\watch typos just written here
dim ds as new dataset
dim cmd as xxxcommand(sqlstring,con)
dim da as new xxxdataadapter(cmd)
da.fill(ds, "sheet1")
cmd.command = ("a new sqlstring")
da.fill(ds, "sheet2")
///

I hope this helps

Cor
Nov 20 '05 #2
On Thu, 29 Jan 2004 09:56:32 +0800, "Phoebe." <ph********@hotmail.com> wrote:

¤ Hi, Good Day!
¤
¤ Reading 1 excel file into a dataset is fine.
¤ How can I read multiple excel with the same data structure into 1 dataset?
¤ How can I append those data?
¤
¤ Can someone help?

Assuming that your connection is to an Excel Workbook, the following example, using the UNION
keyword, should work:

"Select * from [Sheet7$] UNION Select * from [Sheet3$]"
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #3
Thanks Paul,

Problem solved if those worksheet is in 1 excel file.

Mine is same worksheet but different excel file. i.e. datasource is
different.
Currently I have 5 excel file, so i connect using 5 connection and data
selected using 5 dataadapter and fill in using 5 dataset into 1 datagrid.

msConnectString = New System.Data.OleDb.OleDbConnection(
"provider=Microsoft.Jet.OLEDB.4.0; data source=C:\a.xls; Extended
Properties=Excel 8.0;")

msConnectString = New System.Data.OleDb.OleDbConnection(
"provider=Microsoft.Jet.OLEDB.4.0; data source=C:\b.xls; Extended
Properties=Excel 8.0;")

........
' Select the data from Sheet1 of the workbook.

da1 = New System.Data.OleDb.OleDbDataAdapter( "select * from [Sheet1$]",
msConnectString)

da2 = New System.Data.OleDb.OleDbDataAdapter( "select * from [Sheet1$]",
msConnectString)

.......

dsExcel = New System.Data.DataSet()

da1.Fill(dsExcel)

da2.Fill(dsExcel)

.......

dgExcel.DataSource = dsExcel
Can this be solved by connecting 5 excel file using 1 connenction?
Thanks in advanced.

rgds,
Phoebe.

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:u8********************************@4ax.com...
On Thu, 29 Jan 2004 09:56:32 +0800, "Phoebe." <ph********@hotmail.com> wrote:
¤ Hi, Good Day!
¤
¤ Reading 1 excel file into a dataset is fine.
¤ How can I read multiple excel with the same data structure into 1 dataset? ¤ How can I append those data?
¤
¤ Can someone help?

Assuming that your connection is to an Excel Workbook, the following example, using the UNION keyword, should work:

"Select * from [Sheet7$] UNION Select * from [Sheet3$]"
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 20 '05 #4
On Fri, 30 Jan 2004 10:51:44 +0800, "Phoebe." <ph********@hotmail.com> wrote:

¤ Thanks Paul,
¤
¤ Problem solved if those worksheet is in 1 excel file.
¤
¤ Mine is same worksheet but different excel file. i.e. datasource is
¤ different.
¤ Currently I have 5 excel file, so i connect using 5 connection and data
¤ selected using 5 dataadapter and fill in using 5 dataset into 1 datagrid.

You can connect to a specific Workbook source but also include other Workbook sources in your SQL
statement:

"Select * from [Sheet7$] UNION Select * from [Excel 8.0;DATABASE=e:\My
Documents\Book20.xls;HDR=No;IMEX=1].[Table4$]"
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex Shirley | last post by:
Hi I'm still banging my head on how to import an Excel XML spreadsheet into a dataset. The code will work for standard XML files, but not XML files made with Excel (I get 'Specified cast is not...
5
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
3
by: Brad | last post by:
I'm having a problem reading data from an Excel file into a dataset. Can anybody give me an idea of what's happening? I've included the problematic source and the error message to the end of this...
1
by: madhu sudhan | last post by:
HI, I want to read data from excel file and export this data to dataset. I know abt the basics of opening a file using application, workbook and worksheet classes. But i don't know how to read...
2
by: rwiegel | last post by:
I'm trying to read rows from an Excel file and display them in an ASP.NET DataGridview. I am using C# for the code file. I am using OleDb to read from the Excel file. The columns that contain...
1
by: DennisBetten | last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel. What does this code do: As the title says, this code is capable of...
3
by: stephen | last post by:
Hi, I have 5 excel files and they have multiple sheets. I have to read (say sheet 3) of each of the 5 excel files and consolidate them into one. what's the best way to achieve this. if someone...
1
by: sachinkale123 | last post by:
Hi, I am reading excel file and reading values from that I am using provider As : "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + Filename + ";Extended Properties=\"Excel 8.0;Hdr=No;IMEX=1\"";...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.