运行后出现byref参数类型不符Public FilePath As String
Public Cnn As New ADODB.Connection
Public Rcdst As New ADODB.Recordset
Public strSql As StringFunction Getrs(strSql As String) As ADODB.Recordset
With Cnn
FilePath = App.Path & "\realty.mdb"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = .ConnectionString & "Data Source=" & FilePath & ";"
.ConnectionString = .ConnectionString & "Jet OLEDB:"
.Open
End With
With Rcdst
.ActiveConnection = Cnn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = strSql
.Open
End With
End Function
.................
Private Sub Command8_Click() '第一条记录
Dim rs As Recordset If Rcdst.State = 1 Then
Rcdst.MoveFirst
ShowData
Exit Sub
Else
Set rs = Getrs(strSql1)
rs.MoveFirst
ShowData
Exit Sub
End If
Public Cnn As New ADODB.Connection
Public Rcdst As New ADODB.Recordset
Public strSql As StringFunction Getrs(strSql As String) As ADODB.Recordset
With Cnn
FilePath = App.Path & "\realty.mdb"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = .ConnectionString & "Data Source=" & FilePath & ";"
.ConnectionString = .ConnectionString & "Jet OLEDB:"
.Open
End With
With Rcdst
.ActiveConnection = Cnn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = strSql
.Open
End With
End Function
.................
Private Sub Command8_Click() '第一条记录
Dim rs As Recordset If Rcdst.State = 1 Then
Rcdst.MoveFirst
ShowData
Exit Sub
Else
Set rs = Getrs(strSql1)
rs.MoveFirst
ShowData
Exit Sub
End If
解决方案 »
- TextRange的
- 我想设置一个窗口成活动状态,用哪个API?
- 急求如何获取操作系统(WIN2000/XP)当前登陆用户所属用户组类型(属于哪个用户组)!!!
- 新手上路~请指教!
- CSDN 是垃圾,上CSDN 的人更是垃圾,不是我乱说,事实如此,失望,从此不再上这个所谓的中国最大的开发者网站!!!!!
- 高分求EXE文件嵌入本人写的文件中,并在内部调用的方法
- 关于 " 的问题
- 如何判断年龄大于15周岁?
- 急!!UserControl_Resize()什么时候触发?
- 如何在vb下实现一次加载多张图片,然后一张张看,再分批的卸载,是用控件数组?还是用imagelist?具体的方法,源码!!!!!!!!!!!!!!!急!!!!急!!!!!!
- 请问用VB能实现这样的功能吗?
- 字符串如何釋放資源
Dim rs As New Recordset
Public FilePath As String
Public Cnn As New ADODB.Connection
Public Rcdst As New ADODB.Recordset
Public strSql As String
Public SqlWhere As String
Public Myt As Single
Function Getrs(ByVal strSql As String) As ADODB.Recordset
With Cnn
FilePath = App.Path & "\realty.mdb"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = .ConnectionString & "Data Source=" & FilePath & ";"
.ConnectionString = .ConnectionString & "Jet OLEDB:"
.Open
End With
With Rcdst
.ActiveConnection = Cnn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = strSql
.Open
End With
End Function
........................
Private Sub Command8_Click() '第一条记录
On Error GoTo ConnectionERR
Dim strSql1 As String
Dim rs As New Recordset
strSql1 = "select * from rltdata" If Rcdst.State = 1 Then
Rcdst.MoveFirst
ShowData
Exit Sub
Else
Set rs = Getrs(strSql1)
rs.MoveFirst
ShowData
Exit Sub
End If
ConnectionERR:
MsgBox "未能连接到案例库," & Err.Description & "将关闭!", vbCritical, "出错"
Unload Me
Exit Sub
Cnn.Close
Set Cnn = Nothing
End Sub
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = .ConnectionString & "Data Source=" & FilePath & ";"
.ConnectionString = .ConnectionString & "Jet OLEDB:" 多次直接设置连接字符串,当然出错啦
先用一个临时变量连接好字符串后再一次性给.ConnectionString赋值