public conn as adodb.connection
public rs as adodb.recordset
public addflag as boolean '宣告部分
public function opencn(byval cip as string, byval users as string, byval pw as string, byval sjk as string) as boolean '連線模組 填寫資料庫等資訊
dim mag as string
on error goto strerrmag
set conn = new adodb.connection
conn.connectiontimeout = 25
conn.provider = "sqloledb"
conn.properties("data source").value = cip '伺服器的名字
conn.properties("initial catalog").value = sjk '庫名
'conn.properties("integrated security").value = "sspi" '登陸型別
conn.properties("user id").value = users 'sql庫使用者名稱
conn.properties("password").value = pw '密碼
conn.open
opencn = true
if conn.state = 1 then addflag = true
exit function
strerrmag:
mag = "連線失敗!"
call msgbox(mag, vbokonly, "錯誤:")
addflag = false
exit function '連線錯誤訊息
end function
'關閉資料庫,釋放連線
public sub clocn()
on error resume next
if conn.state <> adstateclosed then conn.close
set conn = nothing
end sub
public function openrs(byval strsql as string) as boolean '連線資料庫記錄集
dim mag as string
dim rpy as boolean
on error goto strerrmag
set rs = new adodb.recordset
if addflag = false then rpy = true
with rs
.activeconnection = conn
.cursorlocation = aduseclient
.cursortype = adopenkeyset
.locktype = adlockoptimistic
.open strsql
end with
addflag = true
openrs = true
'end '將記錄集給rs
exit function
strerrmag:
mag = "記錄返回錯誤!"
call msgbox(mag, vbokonly, "錯誤:")
openrs = false
'end
exit function '連線錯誤訊息
end function
public sub clors()
on error resume next
if rs.state <> adstateclosed then rs.clone
set rs = nothing '釋放記錄集
end sub
aspx 到 html 最簡單方法
using system using system.data using system.configuration using system.collections using system.web using system.web.security using system.web.ui usin...
VB獲取系統目錄的簡單方法
private sub command1 click dim file as string file environ windir system32 print file end sub 其實environ 完全可以達到獲取系統目錄的效果 environ 函式 返回 string,它關連於乙個作業系...
as實現右鍵選單的最簡單方法
非常簡單的 把下面 直接放到新建立的flash的第一幀。var linkurl var linktext 連線到我的 定義乙個新的右鍵選單項 var mymenu new contextmenu function gotothisurl function drawline var drawlinei...