- 相關(guān)推薦
asp 數(shù)據(jù)庫連接函數(shù)代碼介紹
以下是SQL連接代碼:
復(fù)制代碼 代碼如下:
Function Open_conn()
dim Conn,Strconn
set Conn=server.createobject("adodb.connection")
Strconn = "Provider = Sqloledb; User ID = 數(shù)據(jù)庫登錄帳號(hào); Password = 數(shù)據(jù)庫登錄密碼; Initial Catalog = 數(shù)據(jù)庫名稱; Data Source = (local);"
Conn.open Strconn
set Open_conn=Conn
If Err Then
err.Clear
Conn.close:set Conn=nothing
Response.Write "對(duì)不起,數(shù)據(jù)庫連接出錯(cuò)。"
Response.End
End If
End Function
調(diào)用方法:
將原來的
復(fù)制代碼 代碼如下:
rs.open sql,conn
改成
復(fù)制代碼 代碼如下:
rs.open sql,Open_conn()
以下是ACCESS連接代碼:
復(fù)制代碼 代碼如下:
Function Open_conn()
dim Dbpath,Conn
Dbpath=server.MapPath("數(shù)據(jù)庫路徑")
set Conn=server.createObject("ADODB.connection")
Conn.open "data source="&dbpath&";provider=microsoft.Jet.OLEDB.4.0;"
set Open_conn=Conn
If Err Then
err.Clear
Conn.close:set Conn=nothing
Response.Write "對(duì)不起,數(shù)據(jù)庫連接出錯(cuò)。"
Response.End
End If
End Function
調(diào)用方法:
將原來的
復(fù)制代碼 代碼如下:
rs.open sql,conn
改成
復(fù)制代碼 代碼如下:
rs.open sql,Open_conn()
【asp 數(shù)據(jù)庫連接函數(shù)代碼介紹】相關(guān)文章:
用php連接oracle數(shù)據(jù)庫的代碼06-28
使用Java程序連接各種數(shù)據(jù)庫的方法07-01
計(jì)算機(jī)三級(jí)數(shù)據(jù)庫知識(shí):數(shù)據(jù)庫在連接中常見錯(cuò)誤解決方法06-28
Android短信數(shù)據(jù)庫基礎(chǔ)詳細(xì)介紹06-28
計(jì)算機(jī)網(wǎng)絡(luò),我對(duì)數(shù)據(jù)庫,ASP.NET比較感興趣,分析一下數(shù)據(jù)庫專業(yè)的就業(yè)前景?07-14
電腦網(wǎng)絡(luò)連接禁用連接出錯(cuò)的做法08-07
電路的連接方法07-03
ASP面試試題及答案07-13