技巧 # 1
小工具The WebThang PathFinder 我们提供了一个非常小的文ASP文件:pathfinder.asp,可以快捷地提供数据库链接代码下载 HERE .
使用方法:
解压文件 上传pathfinder.asp 到你的服务器端(和数据库文件在同一目录中) 通过浏览器运行:www.yoursite.com/data/pathfinder.asp. 你会看到类似下面的显示结果:
DSNLess Connection String is DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\Inetpub\wwwroot\test2\YourDatabase.mdb
OLEDB Connection String is Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\test2\YourDatabase.mdb
5.你所要做的仅仅是修改YourDatabase.mdb为你的数据库文件名,复制到custom connection string 设置窗口中(注意不要忘记在代码前后添加双引号).
技巧 # 2
假如你想创建一个Server.MapPath连接字符串,而数据库文件和你的远端站点ASP文件不在同一个目录下,你可能不能准确写出asp页和数据库文件之间精确路径,怎么办呢?尝试下面的方法
新建一个文件findpath.htm 同你的ASP 文件放到一起 (不要放到 Connections 目录下, 必须和asp文件在同一目录下) 打开findpath.htm输入“Path to Database” . 选择“Path to Database”建立一个超链接,连接到数据库文件. 在属性设置面板中Link文本框中你会看到类似../../mydatabase.mdb 的字符 拷贝字符,粘帖到Server.MapPath中。 STRINGS FOR ALL OCCASIONS
这里是用于连接各种数据库用的链接字符串,请根据你的需要选用。.
ODBC DSNLess Connections:
MS Access ODBC DSNless connection Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\yourpath\dbase.mdb;Uid=Admin;Pwd=pass;
dBase ODBC DSNless connection Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=c:\yourpath\dbase.dbf;
Oracle ODBC DSNless connection Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=admin;Pwd=pass;
MS SQL Server DSNless connection Driver={SQL Server};Server=servername;Database=dbase_name;Uid=sa;Pwd=pass;
MS Text Driver DSNless connection Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=c:\yourpath\;Extensions=asc,csv,tab,txt;Persist Security Info=False;
Visual Foxpro DSNless connection Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=c:\yourepath\dbase.dbc;Exclusive=No;
MySQL DSNless connection driver={mysql}; database=yourdatabase;server=yourserver;uid=username;pwd=password;option=16386;
--------------------------------------------------------------------------------
OLE DB Connections:
MS Access OLE DB connection Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\yourpath\dbase.mdb;User Id=admin;Password=pass;
Oracle OLE DB connection Provider=OraOLEDB.Oracle;Data Source=dbase_name;User Id=admin;Password=pass;
MS SQL Server OLE DB connection Provider=SQLOLEDB;Data Source=machineName;Initial Catalog=dbasename;User ID=sa;Password=pass;
MS SQL Server OLE DB connection using an IP address Provider=SQLOLEDB; Data Source=xx.xx.xx.xx,1433; Network Library=DBMSSOCN; Initial Catalog=dbasename;User ID=sa;Password=pass;
MS Text Driver OLE DB connection "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\yourpath;Extended Properties='text;FMT=Delimited'"
|