MS Access数据库中的连接问题 [英] Connection problem in MS Access Database
本文介绍了MS Access数据库中的连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在开发我使用名称空间的C#Windows Base应用程序
Hi All,
I m developing C# windows base application where name space I used
using System;
using System.Data.OleDb;
class basecon
{
public static string inv = "";
public string connection()
{
string p;
p = Application.StartupPath.ToString() + @"\conn.ini";
private void grid()
{
dgvPartMaster.Columns.Clear();
DataGridViewTextBoxColumn dgvCol = new DataGridViewTextBoxColumn();
con.ConnectionString = Microsoft.VisualBasic.Strings.Trim(obj.connection().ToString());
//请帮助我如何编写oleDb连接路径
谢谢
英德拉吉特
[edit]已添加代码块-OriginalGriff [/edit]
// please help me how to write oleDb connection path
Thanks
Indrajit
[edit]Code block added - OriginalGriff[/edit]
推荐答案
将您的mdb文件放在bin/Debug文件夹中
然后像访问它一样
Put your mdb file in bin/Debug folder
then access it like
string con=@"Provider=Microsoft.Jet.OleDB.4.0;DataSource=abc.mdb";
If you have format other then mdb then Check this[^]
最简单的方法是在服务器资源管理器"窗格中查看数据库.
突出显示您感兴趣的数据库,然后查看属性"窗格-连接字符串将显示在此处.
复制该文件,然后将其粘贴到项目属性的Settings.settings部分中的配置字符串中.如果您以后移动数据库或更改机器,这将使您可以轻松地对其进行更改.
The simplest way is to start by looking at your database in the Server Explorer pane.
Highlight the database you are interested in, and look at the Properties pane - the connection string will be shown there.
Copy that, and paste it into a configuration string in the Settings.settings section of the properties for you project. This will allow you to change it easily if you move your database later, or change machines.
这篇关于MS Access数据库中的连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文