连接路径 [英] Connection Path
问题描述
大家好,
我正在做一个win应用程序,我需要访问微软访问数据库,但路径下面给出了一个异常,找不到数据库,所以任何人都让我知道如何给出路径,如果我们在任何驱动器
中安装安装文件,数据库应该检测到。
public static string appath = @" path \Data.mdb" ;; OdbcConnection con = new OdbcConnection(" Driver = {Microsoft Access Driver(* .mdb)}; Dbq =" + appath +" ;; User Id =; Password =;");
您可以将数据库文件保存在应用程序文件夹中,并将Application.StartupPath用作appPath
public static string appath = System.IO.Path.Combine(Application.StartUpPath," Data.mdb");
OdbcConnection con = new OdbcConnection(" Driver = {Microsoft Access Driver(* .mdb)}; Dbq =" + appath +" ;; User Id =; Password =;");您还可以通过以下链接检查您的连接字符串
Hi All,
I \'m doing a win application where i need to access the microsoft access database, but the path given below throws an exception that database is not found, so anybody let me know how to give the path, and also if we install the setup file in any drives , the databse should detect.
public static string appath = @"path \Data.mdb"; OdbcConnection con = new OdbcConnection(" Driver={Microsoft Access Driver (*.mdb)};Dbq=" + appath + ";User Id=;Password=;");
You can save the database file in your application folder and use Application.StartupPath as appPath
public static string appath = System.IO.Path.Combine(Application.StartUpPath,"Data.mdb"); OdbcConnection con = new OdbcConnection(" Driver={Microsoft Access Driver (*.mdb)};Dbq=" + appath + ";User Id=;Password=;");Also you can check for your connection string from following link
这篇关于连接路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!