且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在csharp中为受密码保护的访问数据库创建连接字符串

更新时间:2023-10-05 11:42:40

尝试使用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?