server|sqlserver| Data | database | database connection | problem
Recently compiled a material management system, with vb6.0+sqlserver2000, in the writing ExecuteSQL function error,
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 = "Query to" & rst. RecordCount & "Record"
End If
Executesql_exit
Set rst = Nothing
Set cnn = Nothing
Exit Function
Executesql_error
msgstring = "Query Error" & Err.Description
Resume Executesql_exit
End Function
Public Function connectstring () as String
ConnectString = "Filedsn=material.dsn;uid=sa;pwd=sa"
End Function
An error occurred while precompiling execution, prompting the subroutine or function undefined, and pointing to executesql_exit, I have added the Microsoft ACTIVEX OBJECTS 2.6 LIBRARY and the data source is set