最近編乙個物資管理系統,用vb6.0+sqlserver2000,在編寫executesql函式時出錯,
public function executesql(byval sql as string, msgstring as string) as adodb.recordset
dim **n as adodb.connection
dim rst as adodb.recordset
dim stokens() as string
on error goto executesql_error
stokens = split(sql)
set **n = new adodb.connection
**n.open connectstring
if instr("insert,delete,update", ucase$(stokens(0))) then
**n.execute sql
msgstring = stokens(0) & "query sucessful"
else
set rst = new adodb.recordset
rst.open trim$(sql), **n, adopenkeyset, adlockoptimistic
set executesql = rst
msgstring = "查詢到" & rst.recordcount & "條記錄"
end if
executesql_exit
set rst = nothing
set **n = nothing
exit function
executesql_error
msgstring = "查詢錯誤" & err.description
resume executesql_exit
end function
public function connectstring() as string
connectstring = "filedsn=material.dsn;uid=sa;pwd=sa"
end function
預編譯執行時出現錯誤,提示子程式或函式未定義,而且游標指向 executesql_exit,我已經把microsoft activex objects 2.6 library 新增了,資料來源也設好了
VB6與SQLServer資料庫連線例項ADO
option explicit dim gobjconn as new cado dim k as integer k gobjconn.connected 資料庫名稱 ip位址 sa sa密碼 if k 0 then label1.caption now 連線 資料庫伺服器失敗!label1.fo...
VB與資料庫 資料庫連線
話說學生管理系統和機房收費系統都完成了,再回來說資料庫的連線真的好嗎?貌似不太好,但是誰讓自己欠賬了呢 除了還,還能有更好的解決方法嗎?前幾天說 紅皮書 中的七個物件。當時的反應哪七個,腦子完全一片空白,不知所云。所以找出來,再看看吧。vb6.0與sqlserver有源資料庫連線,vb6.0中資料訪...
VB與資料庫(4)
vb中資料庫的建立和前面一樣,只是沒有通過屬性視窗來連線記錄源 我們設combo1 的名稱為cmbfield,combo2為cmbname,text1為txtno,text2為txtname,text3為txtjd,text4為txtwd,新增的按鈕為cmdadd,刪除為cmddel,修改為cmde...