请教下客服,在Access的Mdb里,金字塔的VBS是否支持RecordSet记录集的Seek方法?如果支持,应该如何实现?本人测试了好久都没实现。
另外,在使用Find方法时,有时候会出现表里已有数据,但还是定位不了,直接报EOF错误。
多谢!!
多谢客服!测试代码如下:
Sub TestSeek
Set Cnn=CreateObject("Adodb.Connection")
Set Rs=CreateObject("ADODB.Recordset")
Cnn.Open "Provider=MicroSoft.Jet.OLEDB.4.0;Data Source=E:\Test.mdb"
Str="Select * from Table1 Order by StockDate"
Rs.Open Str,Cnn,1,3
Set Rs1=CreateObject("ADODB.Recordset")
Rs1.Open Str,Cnn,1,3
While Not rs1.eof
vDate=Rs1("StockDate")
Rs.Seek vDate,1
if rs.eof then
msgbox Rs1("Date1")&" not found.."
else
End if
Rs1.MoveNext
Wend
End Sub
错误提示:编译器错误 '3251'
当前提供程序不支持"索引"功能必须的界面。
这是百度上搜到的信息,希望读你有用
The Seek method searches the index of a Recordset to find a record that matches the values specified in the keyvalues parameter. If there is a match, the pointer will point to the record specified by the seekoption parameter. If there is no match, the record pointer will be placed at the end of the Recordset.
Seek的作用是:搜索一个记录集的index[索引],从中查找与keyvalues参数中指定的值相匹配的一条记录。如果找到了匹配对象,那么记录指针将指向seekoption参数指定的记录;如果未找到匹配对象,那么记录指针将定位在记录集的末尾处。
Note: To use this method, the provider must support this method and the use of indexes on a Recordset (the Index property). Use the Supports method to determine whether the provider supports seek and indexes.
注意:使用这个方法的前提是:技术提供对象[provider]必须支持这个方法,并且必须在一个记录集参数(索引[index]属性中)中使用索引[index];使用Supports方法可以用来确定技术提供对象[provider]是否支持Seek和index方法。
Note: Set the Index property to the desired index before executing this method.
注意:必须在这个方法执行之前将index属性设置为你希望的index值。
Note: This method can only be used with server-side cursors (not supported when the CursorLocation property value is adUseClient).
注意:这个方法只能用于服务器端的记录指针(当CursorLocation属性值为adUseClient时,则不能获得支持)。
Note: This method can only be used when the Recordset object was opened with the CommandTypeEnum value of adCmdTableDirect.
注意:只有当Recordset对象以adCmdTableDirect中的CommandTypeEnum值打开时,才能使用这个方法。
试试将数据库表字段上加上索引和主键后看看。
ADO的开发都是一样的,你也考虑先在ACCESS上进行开发,等通过后再把代码移植到金字塔