English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

可否列出asp 如何 connect 去 odbc 所需要的 code? 同埋點GET 到個RECORDSET?
(我個DSN 叫 ABC, TABLE 叫 XYZ)

2006-11-27 17:38:07 · 1 個解答 · 發問者 GERMAN 1 in 電腦與網際網路 程式設計

1 個解答

直接 link 你個 access (.mdb) file 吧!

declare DB 的 code:

Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
dbSource = "\db\ABC.mdb"
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data Source=" & server.mappath(".") & dbSource
strConn = Provider & DBPath

Const adStateOpen = 1

connect DB 的 code:

Conn.ConnectionString = strConn
Conn.Open
If Conn.State = adStateOpen Then
DBConnect = True
Else
DBConnect = False
End If

disconnect DB 的 code:

Conn.Close
Set rs = Nothing
Set Conn = Nothing

select record set 的 code:

Dim Sql
Sql = "Select * from XYZ"

Dim RecordSet
Set RecordSet = Conn.Execute(sql)
RecordSet .cursortype = 3

fetch record set 的 code:

RecordSet(1) ............. 第一個 column
RecordSet("HIHI") ............ 名叫 HIHI 的 column

execute update 的 code:

Dim Sql
Sql = "Update XYZ set A = 'N'"

Dim rows .......... row 將會 store update 了的 number of row
Call Conn.Execute(sql, rows)

2006-11-27 17:58:20 · answer #1 · answered by ? 6 · 0 0

fedest.com, questions and answers