问题一:我用了以下语句:
Data1.DatabaseName = App.Path + "\version.mdb"
Data1.RecordSource = "select * from tbresult"
然后使用:
If Not Data1.Recordset.EOF Then Data1.Recordset.MoveFirst 系统提示:“对象变量或with块未设置”,请问是怎么一回事?
问题二:
使用以下语句:
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\old version.mdb"
CN.Open str
Set RS = CN.Execute("select * from 已知条件 order by 节点号 ") n = RS.RecordCount
明明数据库中有数据,为什么n的值老是等于-1?要怎样才能使它正确返回数据的记录数?
问题三:
在问题二中连接了数据库后,要想在MSFlexGrid1中显示数据: Set MSFlexGrid1.DataSource = rs 系统又提示:“对象变量或with块未设置”,请问要怎样才能使MSFlexGrid1显示rs中的数据绑定?
Data1.DatabaseName = App.Path + "\version.mdb"
Data1.RecordSource = "select * from tbresult"
然后使用:
If Not Data1.Recordset.EOF Then Data1.Recordset.MoveFirst 系统提示:“对象变量或with块未设置”,请问是怎么一回事?
问题二:
使用以下语句:
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\old version.mdb"
CN.Open str
Set RS = CN.Execute("select * from 已知条件 order by 节点号 ") n = RS.RecordCount
明明数据库中有数据,为什么n的值老是等于-1?要怎样才能使它正确返回数据的记录数?
问题三:
在问题二中连接了数据库后,要想在MSFlexGrid1中显示数据: Set MSFlexGrid1.DataSource = rs 系统又提示:“对象变量或with块未设置”,请问要怎样才能使MSFlexGrid1显示rs中的数据绑定?
Dim strSql As String
Dim rst As ADODB.Recordset
Dim rowid As Long
With frmBackground
strSql = "select * from orderform_list " & g_strSearch & " order by " & g_strOrderByFields & " asc" '在表名后面加字符串变量strSearch = where fieldname1=XXX and fieldname2=YYY
Set rst = New ADODB.Recordset
rst.Open strSql, conn
.msgorderform.Rows = 1 '初始化起始行号
.msgorderform.Cols = 25
If rst.BOF Then g_dbisnull = True
Do While Not rst.EOF
With .msgorderform
.Rows = .Rows + 1
rowid = .Rows - 1
.TextMatrix(rowid, 0) = IIf(IsNull(Trim(rst.Fields("ID"))), "", Trim(rst.Fields("ID")))
.TextMatrix(rowid, 1) = IIf(IsNull(Trim(rst.Fields("name"))), "", Trim(rst.Fields("name")))
.TextMatrix(rowid, 2) = IIf(IsNull(Trim(rst.Fields("title"))), "", Trim(rst.Fields("title")))
.TextMatrix(rowid, 3) = IIf(IsNull(Trim(rst.Fields("address"))), "", Trim(rst.Fields("address")))
.TextMatrix(rowid, 4) = IIf(IsNull(Trim(rst.Fields("orgname"))), "",
End With
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
End With
End Function
data没有连接到数据库
2
cn.CursorLocation = adUseClient
把MSFlexGrid换成MSHFlexGrid就可以了
cn.CursorLocation = adUseClient
3
MSHFlexGrid