利用ASP存取各種常用類型資料庫(4)

來源:互聯網
上載者:User
  DBPath = "SourceDB=" & Server.MapPath( "DBC資料庫檔案名" )
  ' 串連資料庫
  conn.Open Driver & SourceType & DBPath
  Set CreateDbcRecordset = Server.CreateObject("ADODB.Recordset")
  ' 開啟資料表,參數二為Connection?對象
  CreateDbcRecordset.Open "資料表名或Select語句", conn, 2, 2
  End Function
  5)將Excel97或Excel2000產生的XLS檔案(book)看成一個資料庫,其中的每一個工作表(sheet)看成資料庫表。
  Function CreateExcelRecordset( XLS檔案名稱,Sheet名 )
  Dim conn.Driver,DBPath
  ' 建立Connection對象
  Set conn = Server.CreateObject("ADODB.Connection")
  Driver = "Driver={Microsoft Excel Driver (*.xls)};"
  DBPath = "DBQ=" & Server.MapPath( "XLS檔案名稱" )
  ' 調用Open 方法開啟資料庫
  conn.Open Driver & DBPath
  Set CreateExcelRecordset = Server.CreateObject("ADODB.Recordset")
  ' 開啟Sheet,參數二為Connection對象,因為Excel ODBC驅動程式無法直接用'sheet名來開啟sheet,所以請注意以下的select語句
  CreateExcelRecordset.Open "Select * From ["&sheet&”$]”, conn, 2, 2
  End Function
  6)SQL Server屬於Server級的資料庫,使用時要求比較嚴格,必須要求輸入使用者名稱及密碼才能使用。
  Function CreateSQLServerRecordset(電腦名稱,使用者ID, 使用者密碼,資料庫名稱 資料表或查看錶或Select指令 )
  Dim Params, conn
  Set CreatSQLServerConnection = Nothing
  Set conn = Server.CreateObject("ADODB.Connection")
  Params = "Provider=SQLOLEDB.1"
  Params = Params & ";Data Source=" & Computer
  Params = Params & ";User ID=" & UserID
  Params = Params & ";Password=" & Password
  Params = Params & ".Initial Catalog="&資料庫名稱
  Conn open Paras
  Set CreateSQLServerRecordset = Server.CreateObject("ADODB.Recordset")

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.