C#Windows应用程序中的连接问题 [英] Connection problem in C# windows application

查看:93
本文介绍了C#Windows应用程序中的连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在使用C#Windows基本应用程序,在此我遇到连接问题
我的申请路径是
C:\ Documents and Settings \ Administrator \ My Documents \ Visual Studio 2005 \ Projects \ Test Crystal报告

数据库的路径是
C:\ Documents and Settings \ Administrator \ Desktop \ Product.mdb

我写的代码是
私有OleDbConnection conn = new OleDbConnection();
私有字符串ConStr ="Provider = Microsoft.Jet.OLEDB.4.0;" +数据源=" +;持久安全性信息= False;";

如何编写应用程序路径和数据库路径的连接,请帮忙

谢谢与问候
Indrajit

Hi All,
I m using C# windows base application where I m getting problem for connection
My application path is
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Test Crystal Report

And data base path is
C:\Documents and Settings\Administrator\Desktop\Product.mdb

Code I wrote is
private OleDbConnection conn = new OleDbConnection();
private String ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + ";Persist Security Info=False;";

how to write the connection for application path and database path please help

Thanks & Regards
Indrajit

推荐答案

将数据库添加到服务器资源管理器,并从其属性中获取连接字符串.
Add your database to your server explorer and get the connection string from its properties.


您可以使用 Application.UserAppDataPath [
you can use Application.UserAppDataPath[^] for this purpose. You need to place your mdb in the respective folder. go throgh the url you will find all the details and sample.


将数据库放入bin/Debug文件夹,然后像这样==>
进行访问

Place your database in bin/Debug folder then access it like this ==>


private String ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=Product.mdb;Persist Security Info=False;";


这篇关于C#Windows应用程序中的连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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