asp 資料庫連線函式程式碼介紹

來源:果殼範文吧 7.33K

以下是SQL連線程式碼:

asp 資料庫連線函式程式碼介紹

複製程式碼 程式碼如下:

Function Open_conn()

dim Conn,Strconn

set Conn=teobject("ection")

Strconn = "Provider = Sqloledb; User ID = 資料庫登入帳號; Password = 資料庫登入密碼; Initial Catalog = 資料庫名稱; Data Source = (local);"

Strconn

set Open_conn=Conn

If Err Then

r

e:set Conn=nothing

e "對不起,資料庫連接出錯。"

End If

End Function

呼叫方法:

將原來的

複製程式碼 程式碼如下:

sql,conn

改成

複製程式碼 程式碼如下:

sql,Open_conn()

以下是ACCESS連線程式碼:

複製程式碼 程式碼如下:

Function Open_conn()

dim Dbpath,Conn

Dbpath=server.MapPath("資料庫路徑")

set Conn=teObject("ection")

"data source="&dbpath&";provider=B.4.0;"

set Open_conn=Conn

If Err Then

r

e:set Conn=nothing

e "對不起,資料庫連接出錯。"

End If

End Function

呼叫方法:

將原來的

複製程式碼 程式碼如下:

sql,conn

改成

複製程式碼 程式碼如下:

sql,Open_conn()

熱門標籤