我是菜鸟,最近在仿照书上说的练习做一个物资管理系统,用的是vb6.0+sqlserver2000
其中在添加函数executesql时,出现了问题,函数内容如下:
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
预编译执行时,总是提示 子程序或函数未定义,而且指向executesql_exit,我已经把microsoft activex objects 2.6 library 添加了,数据源odbc也设好了
不清楚是怎么回事,望各位大虾指点一二
新闻热点
疑难解答