VB界面怎么显示SQL中符合条件的纪录?毕业设计困难,急!
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,EXECUTE", _
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
Private Sub Command4_Click()
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
Dim rr As String
rr = InputBox("请输入您想查找的名称:", "提示信息")
SQL = "select date,name from ruku where name='" & rr & "'" '关键是我怎么在VB界面中显示数据库 中 符 合查询条件得表记录
Set mrc = ExecuteSQL(txtSQL, Msgtext)
Unload RCX
RCX.txtSQL = SQL RCX是我入库查询界面,能帮我改改最好,非常感谢
RCX.Show
End Sub
[ 本帖最后由 future 于 2006-4-12 15:59 编辑 ]