使用c#打开Office数据库 [英] Open Office database with c#

查看:145
本文介绍了使用c#打开Office数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



目前我有开放的办公室数据库。现在我需要将数据库数据提供给c#windows form应用程序。我想用连接字符串连接开放式办公室数据库,并从c#获取数据集。谁能帮我。

谢谢,

解决方案

http://wiki.services.openoffice.org/wiki/Database [ ^ ]应该为您提供一些解决方案。


我只想在c#中设置与数据库的连接

是的,这是可能的,因为你必须遵循一些步骤:



1)首先添加

  使用System.Data.OleDb; 

在CS文件的顶部。



2)创建连接字符串并打开连接。

访问2007

< pre lang =c#> string ConnStr = @ Provider = Microsoft.ACE.OLEDB.12.0;数据源= D:\abc.mdb; Jet OLEDB:数据库Pa提供ssword =密码;

OleDbConnection MyConn = new OleDbConnection(ConnStr);





3)打开此连接。

 MyConn.Open(); 





4)为命令和读者创建对象以从访问数据库获取数据。

 OleDbCommand Cmd =  new  OleDbCommand(StrCmd,MyConn);; 
OleDbDataReader ObjReader = Cmd.ExecuteReader();





5)现在通过读者对象来获取数据



  if (ObjReader!=  null 
{

}





6)完成处理后

< pre lang =c#> ObjReader.Close();
MyConn.Close();


https://wiki.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0 [ ^ ]



这有你的和我的aswers

:)

Peace Out Buddy


HI,

Currently I have open office database. Now I need to get that database data to c# windows form application. I want to connect the open office database with connection string and get the dataset from c#. Can any one help me.
Thank you,

解决方案

http://wiki.services.openoffice.org/wiki/Database[^] should provide you with some solutions.


I just want to set the connection with the database in c#
Yes it is possible, for that you have to follow some steps:

1) First add

"using System.Data.OleDb;"

at to top of the CS file.

2) Create connection string and open connection.
For access 2007

string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\abc.mdb;Jet OLEDB:Database Password=password";

OleDbConnection MyConn = new OleDbConnection(ConnStr);



3) Open this connection.

MyConn.Open();



4) Create object for command and reader to get the data from access database.

OleDbCommand Cmd =  new OleDbCommand(StrCmd, MyConn);;
 OleDbDataReader ObjReader = Cmd.ExecuteReader();



5) Now lood through the reader object to get the data

if (ObjReader != null)
{

}



6) After completing the processing

ObjReader.Close();
MyConn.Close();


https://wiki.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0[^]

This has your and mine aswers
:)
Peace Out Buddy


这篇关于使用c#打开Office数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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