Click here to Skip to main content
10,500,000 members (76,995 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 21: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 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=****];
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 3

I think I should introduce you a method, no method is more suitable than it.It needs a third party library .net dataexport[^] can export data from command,database,listview to acess,pdf,excel,word,rtf,csv,sylk,dbf,dif,csv,sql script,clipboard. below is the source code to export data to access:

            OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source="".\..\database\demo.mdb"";Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";
            OleDbCommand command = new OleDbCommand();
            command.CommandText = "select * from parts";
            command.Connection = connection;
            Spire.DataExport.Access.AccessExport accessExport1 = new Access.AccessExport();
            accessExport1.DatabaseName = "test.mdb";
            accessExport1.TableName = "ExportData";
            accessExport1.SQLCommand = command;

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 489
1 OriginalGriff 328
2 Mehdi Gholam 145
3 Sascha Lefèvre 135
4 KarstenK 115
0 Sergey Alexandrovich Kryukov 9,308
1 OriginalGriff 8,352
2 Sascha Lefèvre 3,334
3 Maciej Los 2,956
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 26 Oct 2012
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