| 发表于:2007-04-04 14:37:36 楼主 |
请帮忙看看这段代码错在哪里?老提示无法找到数据源 public sub main() if app.previnstance = true then msgbox "程序已经运行,无法再次执行. ", vbokonly + vbinformation, "系统提示 " end end if connstr = "provider=sqloledb.1;persist security info=false;user id=sa;initial catalog=cbxx;data source=zsm2 " app.helpfile = app.path & "\help.chm " load sfck sfck.show end sub public function exesql(byval sql as string) as adodb.recordset on error goto errhandler: dim cn as adodb.connection dim rs as adodb.recordset dim strarray() as string set cn = new adodb.connection set rs = new adodb.recordset strarray = split(sql) cn.open connstr if strcomp(ucase$(strarray(0)), "select ", vbtextcompare) = 0 then rs.open trim$(sql), cn, adopenkeyset, adlockoptimistic set exesql = rs else cn.EXECute sql end if exesql_exit: set rs = nothing set cn = nothing exit function errhandler: ' 显示错误信息 msgbox "错误号: " & err.number & " 错误信息: " & err.description, vbexclamation resume exesql_exit end function dim sqlfindjh, sqlfindjh2 as string if gsh.text = " " then msgbox "请输入给水号 ", vbexclamation + vbokonly, "系统提示 " exit sub end if dim rs as adodb.recordset sqlfindjh = "select dece_one from user_js1 where dece_one= ' " & trim(gsh.text) & " ' " set rs = exesql(sqlfindjh) dim rsjh as adodb.recordset sqlfindjh2 = "select * from user_js1 where dece_one= ' " & trim(gsh.text) & " ' " set rsjh = exesql(sqlfindjh2) yhmc = rsjh( "name ") scjl = rsjh( "last_data ") zcjl = rsjh( "this_data ") |
|
|
|
|