Scripts and Examples

ASP Scripts
 ¤ODBC DSN Connection String:
  oConn.Open "DSN=mySystemDSN"

 ¤DSN-Less Connection String for .mdb file:
  oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(".") & "/myDb.mdb;User Id=admin;Password="

 ¤DSN-Less Connection String for Excel page:
  oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/somepath/mySpreadsheet.xls;Extended Properties=""Excel 8.0;HDR=Yes"""

' Where "HDR=Yes" means that there is a header row in the cell range
' (or named range), so the provider will not include the first row of the
' selection into the recordset. If "HDR=No", then the provider will include
' the first row of the cell range (or named ranged) into the recordset.

 ¤DSN-Less Connection String to a text file:
  oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/somepath/;Extended Properties=""text;HDR=Yes;FMT=Delimited"""

' Then open a recordset based on a select on the actual file

oRs.Open "Select * From MyTextFile.txt", oConn, adOpenStatic, adLockReadOnly, adCmdText

 ¤Connection to MS SQL database:
  oConn.open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=USERNAME;Initial Catalog=DATABASE;Data Source=QUICK;password=PASSWORD"

 ¤Connection to MySQL Database:
  oConn.open "Provider=MSDASQL; DRIVER={MySQL ODBC 3.51 Driver}; Server=HOST; UID=USERNAME; PWD=PASSWORD; database=DATABASE; Option=16387"

 PhP Scripts
 ¤DSN Connection String:
  # connect to a DSN "mydb" with a user and password "marin"
$connect = odbc_connect("mydb", "marin", "marin");

 ¤DSN-Less Connection String for .mdb:
  $db = ADONewConnection('access');
$dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:/inetpub/adodb/northwind.mdb;Uid=Admin;Pwd=;";
$db->Connect($dsn);

 ¤DSN-Less Connection String for MS SQL Server:
  $db = ADONewConnection('odbc_mssql');
$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
$db->Connect($dsn,'userid','password');

 ¤Connection to MySQL:
  function connect() {
mysql_connect("IP/SERVER","USERNAME","PASSWORD") or die("Problem DataBase Connection");
mysql_select_db("DATABASENAME") or die("Could not select database");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值