img wangxinwen

Scripts and Examples

发表于2004/6/29 15:00:00  442人阅读

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=;";

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

  ¤ 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");
0 0


取 消