資料庫鏈結類

2021-03-31 10:28:31 字數 1933 閱讀 8479

class clsconn

private flag       'flag = 1: ac資料庫 flag = 0 :sql資料庫

private connstr    '連線字串

'___________sql資料庫相關引數_____________

private sqldatabasename ' sqlserver資料庫名

private sqluser ' sqlserver資料庫使用者名稱

private sqlpassword ' sqlserver資料庫密碼

private sqllocalname '鏈結名,本地用local 外地用ip

'—————————————access資料庫相關引數————————————

private datapath 'access資料庫存放在址

'_________初始化類_____________

private sub classinitialize()

sqldatabasename=""

sqluser=""

sqlpassword=""

sqllocalname=""

datapath=""

flag=""

connstr=""

end sub

'__________類結束_____________

private sub classterminate()

end sub

public property let flag_(iflag)

flag=iflag

end property

public property let datapath_(idatapath)

datapath=idatapath

end property

public property let sqldatabasename_(isqldatabasename)

sqldatabasename=isqldatabasename

end property

public property let sqluser_(isqluser)

sqluser=isqluser

end property

public property let sqlpassword_(isqlpassword)

sqlpassword=isqlpassword

end property

public property let sqllocalname_(isqllocalname)

sqllocalname=isqllocalname

end property

public property get iconnstr()

iconnstr = connstr

end property

'__________建立鏈結____________

public function openconnect()

dim tempconn

on error resume next

set tempconn = server.createobject("adodb.connection")

tempconn.open connstr

set openconnect = tempconn

set tempconn = nothing

if err.number <> 0 then

err.clear

set openconnect=nothing

'response.redirect("")  '轉向自定義錯誤頁面

response.write ("出錯了。。")

response.end()

end if

end function

end class

%>

資料庫鏈結

1 oracle8 8i 9i資料庫 thin模式 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 orcl orcl為資料庫的sid strin...

資料庫鏈結遠端資料庫查詢

建立鏈結伺服器 exec sp addlinkedserver srv lnk sqloledb 遠端伺服器名或ip位址 exec sp addlinkedsrvlogin srv lnk false null,使用者名稱 密碼 go 查詢示例 select from srv lnk.資料庫名.db...

jdbc資料庫鏈結之抽取工具類

jdbc工具類抽取分為兩部分 1.建立連線 2.關閉所有鏈結。案例如下 public class dbutils catch classnotfoundexception e 建立連線 public static connection getconnection throws sqlexceptio...