- UID
- 386647
- 帖子
- 12775
- 精华
- 2
- 威望
- 7
- 阅读权限
- 100
- 性别
- 男
- 来自
- 仙灵洞天
- 注册时间
- 2006-10-25
|
33#
发表于 2007-6-28 16:08
| 只看该作者
ExecuteSQL没有封装
在MOD模块里
Public Function ExecuteSQL(ByVal SQL _
As String, MsgString As String) _
As ADODB.Recordset
'executes SQL and returns 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 successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, _
adOpenKeyset, _
adLockOptimistic
'rst.MoveLast 'get RecordCount
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
我这里日文VB6 没办法显示出中文.. |
|