Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I want to export data from the .mdb file which is in my folder to excel file in c#,
how to do this anyone help me with piece of code.
thanx in advance
sushil

What I have tried:

I tried using file copy(".mdb", "excel"), but it is not correct i think,
so is there any good way to do this,

also i search on google but most of solution are directly using database connection,
but in my case .mdb file is in folder.

Note: Here i am creating excel file programmatically.

plz hel me.
Posted
Updated 18-Jul-16 2:27am
v2

C# Export Table to Excel - Stack Overflow[^]

At first read all the tables in .mdb to a dataset then refer above link .Hope u understand :)
 
Share this answer
 
v2
Comments
Member 11859517 18-Jul-16 8:51am    
thanks NagaNimesh,
how to fill dataset my mdb file is in folder, befor i tried like this also,
do u know how to do this?
NagaNimesh 11474558 18-Jul-16 8:55am    
yes,put your code what u had tried i will help u
NagaNimesh 11474558 18-Jul-16 8:58am    
http://sizious.com/2015/05/11/how-to-load-an-access-database-into-a-dataset-object-in-c/
Member 11859517 18-Jul-16 9:02am    
string source = @"D:\SushilBhat\Development\SCADA Copying file\SCADA\CustomerData.mdb";

DataSet dataset = new DataSet();

dataset.DataSetName = System.IO.Path.GetFileNameWithoutExtension(source);


here i am getting Table count 0;
NagaNimesh 11474558 18-Jul-16 9:11am    
System.IO.Path.GetFileNameWithoutExtension(source) will return only the name like CustomerData here you did not extract the tables in mdb file.
System.IO.Path.GetFileNameWithoutExtension means will ge the file name like CustomerData ant not with extension like .mdb.understand??
You don't export it from MDB, you should try importing it into Excel.
That's pretty easy: How Do I Import Microsoft Access® Data into Excel® | Inbox Email & Resource Center[^]
 
Share this answer
 
Comments
Member 11859517 18-Jul-16 8:32am    
heyy thanks,,
displaying exactly same that i want. But i want same in programmatically, like on button click.
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900