标题:请教,,SQL与VB连接出问题。
只看楼主
lijifeng
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-3-16
 问题点数:0 回复次数:1 
请教,,SQL与VB连接出问题。
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
搜索更多相关主题的帖子: SQL cnn ADODB Recordset String 
2007-03-16 16:28
lijifeng
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-3-16
得分:0 
高手 请教,指点
2007-03-16 16:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-124648-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015771 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved