使用访问数据库连接字符串路径的C#设置中的问题 [英] Problem in C# setup with access database connection string path

查看:124
本文介绍了使用访问数据库连接字符串路径的C#设置中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个窗口窗体(C#)窗口应用程序的设置,我使用ms access 2003数据库我的意思是(mm.mdb)文件。问题是当我调试设置然后它运行得非常好没有任何问题但是当我创建安装程序并将其安装在我的电脑上时发生数据库错误

错误是





您的应用程序中发生了未处理的异常。如果单击继续,应用程序将忽略此错误并继续运行。

操作必须使用可更新的查询




我知道这是一个Connectionstring路径问题



因为当我给出数据库的完整路径然后设置运行非常好但是当我更改连接字符串时。我的意思是当我使用这个路径时。

string strcon =Provider = Microsoft.Jet.OLEDB.4.0; Data Source =+ Application.StartupPath +\\Data\\Mahavir1 .mdb; Persist Security Info = True;

然后发生错误







请帮助Immedaitely谢谢

解决方案

您好Veenu,

当您设置并安装应用程序时,您的应用程序exe将位于一些位置说:

C:\Program Files \ MyApplication

现在,DataSource = Application.StartupPath +\\Data \\Mahavir1.mdb ;坚持安全信息=真;

表示你​​的mdb文件应该出现在

数据文件夹中,该文件夹将是包含你的exe的文件夹中的子文件夹。

请将其粘贴在那里并告诉我你是否还面临同样的问题。



这里有另一个解决方案:链接



谢谢。



Kishor


你好,

在Real Time Situaton中,Conection字符串在app.config文件中。试试放置连接app.config file.Bco​​z中的字符串,有些情况下客户端数据库被更改。



尝试参考文章

得到-连接字符串-从应用内-Config- in-C#



希望它能帮助你。



快乐编码: - )

Hi, I am creating a setup of window forms (C#) window application and i used ms access 2003 database i mean (mm.mdb) file .The Problem is when i debug setup then it runs very well without any problem but when i create setup and install it in my pc then database error occured
The error is


Unhandled exception has occured in your application. If you click Continue.the application will ignore this error and attemt to continue.
Operation must use an updateable query


I know this is a Connectionstring path problem

Beacuse when i gave full path of database then setup run very fine But when i change connectionstring . I mean when I use this Path.
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Data\\Mahavir1.mdb;Persist Security Info=True";
Then error occur



Please Help Immedaitely Thanks

解决方案

Hi Veenu,
When you set up and install the application, your application exe will be at some location say:
C:\Program Files\MyApplication
Now, DataSource=Application.StartupPath + "\\Data\\Mahavir1.mdb;Persist Security Info=True";
means your mdb file should be present in
Data folder which will be a sub folder in folder containing your exe.
Please paste it over there and let me know if you still face the same issue.

There is another solution found here: Link

Thanks.

Kishor


Hello ,
In Real Time Situaton,Conection String is there in app.config file.Try To Put the connection string in app.config file.Bcoz , there are situations when client Database is being changed.

Try To Refer the article
get-Connection-String-from-App-Config-in-C#

Hope It Heps You.

Happy Coding :-)


这篇关于使用访问数据库连接字符串路径的C#设置中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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