Click here to Skip to main content
11,577,710 members (38,794 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Windows Application
Hi Friends ,

I am New To Windows Application, i wanna Export Sql Database Tables to Access MDB File using C sharp Coding in Windows Application , so can any help me for the Same . Thanks in Advance.

Saravana Kumar.M
Posted 24-Oct-12 20:39pm
sinhasourabh at 25-Oct-12 2:41am
try to use import data feature of access.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Open sql Server Management Studio and follow the following steps
   - Right Click on Database GoTo Task -> Export Data
   - In the choose a source scree
       - Select source database and provide the credentials 
       - Press Next
   - In the choose a destination screen
       - Select Destination as Microsoft Access
       - Provide a file Path. User id and password if you want to configure
   - Select option as copy data from one or more table or view and say next
   - you will see all the tables in database select the respective tables 
     which you want to export and finish
It will export the respective tables in the mdb file.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try the following snippette:

//Using JET.OLEDB :
System.Data.OleDb.OleDbConnection AccessConn = new 
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Test Files\\db1.mdb");
//Using ACE.OLEDB :
//System.Data.OleDb.OleDbConnection AccessConn = new
//System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Test Files\\db1.mdb")

//New table, using SELECT INTO
System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand("SELECT * INTO Orders FROM [Orders] IN '' [ODBC;Driver={SQL Server};Server=(local);Database=Northwind;Trusted_Connection=yes];", AccessConn);
//Existing table, using INSERT INTO 
//Dim AccessCommand As New System.Data.OleDb.OleDbCommand("INSERT INTO [ORDERS] SELECT * FROM [Orders] IN '' //[ODBC;Driver={SQL Server};Server=(local);Database=Northwind;Trusted_Connection=yes];", AccessConn)

sinhasourabh at 26-Oct-12 1:52am
You are exporting only data from order table, not the entire table (schema + data) to mdb .
Kuthuparakkal at 26-Oct-12 7:19am
Read it fully before vomiting sheett
sinhasourabh at 26-Oct-12 7:30am
Execute this 'sheett' with a blank MDB and then tell how much this 'sheett' work.
Kuthuparakkal at 26-Oct-12 8:09am
You should understand that Select INTO would create new table. Learn to read and digest and use your brain
hayta6891 at 4-Jun-14 5:22am
It works fine for me to export mssql to mdb.
I just changed :
SELECT * INTO {New Table Name} FROM {Old Table Name} IN '' [ODBC; Driver={SQL Server}; Server=****; Database=****; UID=****; PWD=****];

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

  Print Answers RSS
0 DamithSL 180
1 Peter Leow 180
2 Richard MacCutchan 125
3 Abhinav S 125
4 OriginalGriff 115
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 681
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 27 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100