如何在csharp中为受密码保护的访问数据库创建连接字符串 [英] how do create connection string in csharp for password protected access database

查看:65
本文介绍了如何在csharp中为受密码保护的访问数据库创建连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有



在我的csharp应用程序中我想设置密码保护访问数据库的连接字符串...



i用这种方式创建访问数据库:



用独家和设置密码打开数据库...



现在我创建如下连接字符串:



public static string strconnection = string.Format(@Provider = Microsoft.Jet.OLEDB。 4.0;数据源= {0} \FDA_DB.mdb,Application.StartupPath.ToString())+; Jet OLEDB:数据库密码= 12345;;





但不起作用......



请帮帮我



非常感谢

hi all

in my csharp application i want to set connection string for password protected access database ...

i create access databse with this way :

open database with Exclusive and set password ...

now i create connection string like below :

public static string strconnection = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\FDA_DB.mdb", Application.StartupPath.ToString())+";Jet OLEDB:Database Password=12345;";


but it not work ...

please help me

thanks a lot

推荐答案

尝试使用Server Explorer窗格在VS中设置连接:

1)打开服务器资源管理器。

2)右键单击数据连接。并选择添加连接

3)在随后的对话框中,选择您的DataSource(Microsoft Access数据库文件)和数据库,指定安全信息,然后按测试连接 ;按钮。

4)当连接正常时,按确定

5)在服务器资源管理器窗格中突出显示数据库,然后查看属性窗格。将显示连接字符串的工作示例,您可以将其复制并粘贴到您的应用程序或配置文件中。
Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource ("Microsoft Access Database File"), and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.


更像是什么:



How about something more like:

public static string strconnection = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\FDA_DB.mdb", Application.StartupPath.ToString())+";Jet OLEDB:Database Password=12345;";;







public static string strconnection = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\FDA_DB.mdb;Jet OLEDB:Database Password=12345;", Application.StartupPath.ToString());





你需要ToStri吗? ng?



您是否应该使用JET?还是ACE?你得到什么错误?



And do you need the ToString?

And should you be using JET? Or ACE? What error do you get?


这篇关于如何在csharp中为受密码保护的访问数据库创建连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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