日期:2008-10-18  浏览次数:20403 次

 

我是菜鸟,最近在仿照书上说的练习做一个物资管理系统,用的是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也设好了
不清楚是怎么回事,望各位大虾指点一二