Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
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.

Regards,
Saravana Kumar.M
Posted
Comments
[no name] 25-Oct-12 2:41am    
try to use import data feature of access.

HTML
Hi

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.
 
Share this answer
 
v2
Try the following snippette:

C#
//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")

AccessConn.Open();

//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)

AccessCommand.ExecuteNonQuery();
AccessConn.Close();
 
Share this answer
 
Comments
[no name] 26-Oct-12 1:52am    
You are exporting only data from order table, not the entire table (schema + data) to mdb .
Kuthuparakkal 26-Oct-12 7:19am    
Read it fully before vomiting sheett
[no name] 26-Oct-12 7:30am    
Execute this 'sheett' with a blank MDB and then tell how much this 'sheett' work.
Kuthuparakkal 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 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)



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