如何导出SQL表以访问MDB [英] How to Export SQL Tables To Access MDB

查看:58
本文介绍了如何导出SQL表以访问MDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我是Windows应用程序的新手,我想在Windows应用程序中使用C sharp Coding导出Sql数据库表来访问MDB文件,所以任何帮助我同样的。在此先感谢。



问候,

Saravana Kumar.M

解决方案

 Hi 

打开sql Server Management Studio并按照以下步骤操作

- 右键单击​​Database GoTo任务 - >导出数据

- 在选择源scree
- 选择源数据库并提供凭据
- 按Next

- 在选择目的地screen
- 选择Destination as Microsoft Access
- 提供文件路径。用户ID和密码如果要配置

- 从一个或多个表或视图中选择选项作为复制数据并说下一个

- 您将看到数据库中的所有表选择要导出的各个表
并完成

它将导出mdb文件中的相应表。


< blockquote>尝试以下代码片段:



  //  使用JET.OLEDB: 
System.Data.OleDb.OleDbConnection AccessConn = new
系统。 Data.OleDb.OleDbConnection( Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\\测试文件\\db1.mdb);

// 使用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();

// 新表,使用SELECT INTO
系统。 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);

// 现有表,使用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();


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

解决方案

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.


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

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();


这篇关于如何导出SQL表以访问MDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆