我是菜鳥,最近在仿照書上說的練習做一個物資管理系統(tǒng),用的是vb6.0+sqlserver2000
其中在添加函數(shù)executesql時,出現(xiàn)了問題,函數(shù)內容如下:
public function executesql(byval sql as string, msgstring as string) as adodb.recordset
dim cnn as adodb.connection
dim rst as adodb.recordset
dim stokens() as string
on error goto executesql_error
stokens = split(sql)
set cnn = new adodb.connection
cnn.open connectstring
if instr("insert,delete,update", ucase$(stokens(0))) then
cnn.execute sql
msgstring = stokens(0) & "query sucessful"
else
set rst = new adodb.recordset
rst.open trim$(sql), cnn, adopenkeyset, adlockoptimistic
set executesql = rst
msgstring = "查詢到" & rst.recordcount & "條記錄"
end if
executesql_exit
set rst = nothing
set cnn = 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
預編譯執(zhí)行時,總是提示 子程序或函數(shù)未定義,而且指向executesql_exit,我已經(jīng)把microsoft activex objects 2.6 library 添加了,數(shù)據(jù)源odbc也設好了
不清楚是怎么回事,望各位大蝦指點一二
新聞熱點
疑難解答