如何使用C#创建Microsoft Access数据库 [英] How do I create Microsoft Access Database using C#

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

问题描述

我是.NET编程的新手,我已经用SQLServer数据库在C#中完成了一个数据库.有人可以指导我了解如何使用MS Access数据库,因为我一无所知.请不要给链接

Guys I am new to .NET Programming and I have already done a database in C# with SQLServer database. Can someone take me through on how to work with MS Access databases coz i have no clue. Please dont jus give links

推荐答案

使用MSAcess创建连接并打开连接对象.使用它作为您的要求.



您必须遵循以下步骤:-

1)首先添加"using System.Data.OleDb;"在CS文件的顶部.
2)创建连接字符串并打开连接.
对于Access 2007

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

OleDbConnection MyConn =新的OleDbConnection(ConnStr);

3)打开此连接.

MyConn.Open();


4)为命令和读取器创建对象以从Access数据库获取数据.

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


5)现在遍历阅读器对象以获取数据

如果(ObjReader!= null)
{
}

6)完成处理后

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



谢谢,
安培莎(Ambesha)
Create a connection with MSAcess and open the conection object . use it as your requirement.



You have to follow the following 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();



Thanks,
Ambesha


严重地,添加请不要提供链接"无济于事,因为我们 最好的办法是 为您提供链接.

另一种选择是让我们重复地重复散列相同的材料,并可能忘记包含重要的材料.

Google在这里是您的朋友:有成百上千(如果不是成千上万)的初学者指南,说明如何在C#下使用Access.看一下其中的一些,如果您已经可以使用Sql Server,这并不困难. (在大多数情况下,使用一组不同的类名和不同的连接字符串):
Seriously, adding "Please dont jus give links" doesn''t help, because the best thing we can do is to give you links.

The alternative is for us to re-hash the same material repeatedly, and potentially forget to include important material.

Google is your friend here: there are hundreds (if not hundreds of thousands) of beginners guides to using Access under C#. Look at some of them, it isn''t difficult if you can already use Sql Server. (It''s pretty much a case of using a different set of class names, and a different connection string): https://www.google.com/search?source=ig&hl=en&rlz=&q=work+with+MS+Access+database&btnG=Google+Search&meta=lr%3D&aq=f&oq=#hl=en&sugexp=les%3Beesh&gs_nf=3&tok=9icylW7ibqNahzmabHh_WA&pq=work%20with%20ms%20access%20database&cp=31&gs_id=c&xhr=t&q=work%20with%20MS%20Access%20database%20c%23&pf=p&lr=&safe=off&sclient=psy-ab&oq=work+with+MS+Access+database+c%23&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=5213d3a4531c870f&bpcl=35466521&biw=1544&bih=815[^]


只需访问此链接,即可获得关于在projectproject本身上使用ms访问的特别文章.


链接:
使用Microsoft Access在C#中的简单电影数据库 [^ ]
Just visit this link its a special article of using ms access on codeproject itself.


Link: Simple Movie Database in C# using Microsoft Access[^]


这篇关于如何使用C#创建Microsoft Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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