﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Релиб / ASP / Веб-программирование  / RecordSet.RecordCount = -1 / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Релиб</description><link>http://relib.com/forums/</link><webMaster>robot@relib.com</webMaster><lastBuildDate>Thu, 08 Jan 2009 06:49:19 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>Привет ребята! Когдато и я сталкивался с такой проблемой, и конечно же воспользовался решением подобно(http://www.aspfaq.com/faq/faqShow.asp?fid=24), но... меня не удовлетворило то что я не знал значение этих магических цифр:) и поэтому я познал таки эту тайну... и делюсь ею с вами (для тех кто не знает этих параметров ADO) The Open method is the most powerful and versatile method of retrieving data from your database. You can set the ActiveConnection, Source, LockType, and CursorType properties on the Recordset prior to using the Open method, or you can supply this data in its parameters, all of which are optional:Source This parameter accepts a Variant. You can use the Source parameter to specify the query string or Command object you want to use. If you do use a Command object in this parameter, be sure to leave the ActiveConnection parameter on this method blank. Instead, set the ActiveConnection property on the Command object. This parameter can also contain a table name, a stored procedure call, a URL, a filename, or a Stream object.ActiveConnection This parameter accepts a Variant in the form of a connection string or an open Connection object, just like the ActiveConnection property.CursorType This parameter accepts a CursorTypeEnum value. (See page 60 for a list of CursorTypeEnum values.)LockType This parameter accepts a value from LockTypeEnum. (See page 67 for a list of LockTypeEnum values.)Options This parameter accepts a CommandTypeEnum value and/or a combination of asynchronous ExecuteOptionEnum constants, as respectively shown in the following two tablesгде значения CursorTypeEnum могут быть равны равны:adUseServer  2  Default; uses the OLE DB provider and/or database to manage the results of your queries adUseClient  3  Uses the ADO Cursor Engine to manage the results of your queries adUseClientBatch  0  Hidden; equivalent of adUseClient adUseNone 1 Hidden, undocumented, and unsupported (That warning should suffice.) а значения LockTypeEnum могут быть равны равны: adLockReadOnly 1 Default; the Recordset is read-only. adLockPessimistic 2 ADO relies on the OLE DB provider to ensure that your update attempt will succeed. adLockOptimistic 3 The data is not locked until you call Update. adLockBatchOptimistic 4 Modifications to your data are cached until you call UpdateBatch. Ну вот в принципе и всё Ж) Кому что не понятно, переспросите - я переотвечу! :) Желаю удачи!</description><pubDate>Sun, 07 Jan 2001 01:28:00 GMT</pubDate><dc:creator>burinoff</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>RecordCount после открытия Recordset равен -1. Нужно сделать MoveLast MoveFirst и тогда он заполниться. А в Access чтобы подсчитать уникальные записи надо писать Select Distinctrow Count(*)</description><pubDate>Fri, 05 Jan 2001 17:26:00 GMT</pubDate><dc:creator>phwp</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>Да, действительно, именно так все и было ;-)</description><pubDate>Thu, 04 Jan 2001 17:51:00 GMT</pubDate><dc:creator>Sergik</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>А может дело в &amp;quot;Recordcount is not supported with the default forward-only cursor.&amp;quot;</description><pubDate>Wed, 03 Jan 2001 15:53:00 GMT</pubDate><dc:creator>diklang</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>Спасибо! :)</description><pubDate>Wed, 06 Dec 2000 12:39:00 GMT</pubDate><dc:creator>Alexey</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>отвечаю сам себе :-)http://www.aspfaq.com/faq/faqShow.asp?fid=24</description><pubDate>Wed, 06 Dec 2000 12:29:00 GMT</pubDate><dc:creator>Sergik</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>БД сделана в программе Access 2.0Я сделал системный DSN (в ODBC), выбрал базу .mdb, дал название - остальное по умолчаниюСоединение:set Connection=server.createObject(&amp;quot;ADODB.Connection&amp;quot;)Connection.open(&amp;quot;имя_моей_DSN&amp;quot;)Рекордсет:set rs=server.createObject(&amp;quot;ADODB.Recordset&amp;quot;)set rs=Connection.execute(&amp;quot;select distinct type_list from list_table&amp;quot;)--=--count=rs.recordCount (возвращает -1)--=--rs.moveLast  (пишет ошибку: &amp;quot;Набор строк не поддерживает обратную передачу&amp;quot;)БД не пустая</description><pubDate>Wed, 06 Dec 2000 12:12:00 GMT</pubDate><dc:creator>Sergik</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>Напиши, что значит &amp;quot;старая БД&amp;quot;, это какая? И напиши свою строку подключения к БД (а то у меня были недавно проблемы только из-за ее формата) и с какими параметрами окрываешь рекордсет, а то может ты его только &amp;quot;форвард&amp;quot; или как-то еще пытаешься открыть...</description><pubDate>Wed, 06 Dec 2000 12:02:00 GMT</pubDate><dc:creator>Alexey</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>Дело не в этом, при попытке узнать кол-во записей с помощью MoveLast (например rs.MoveLast;count=rs.Absoluteposition) он ругается (при выполнении MoveLast) &amp;quot;Набор строк не поддерживает обратную передачу&amp;quot;, пробовал еще так: set rs=DBConnection.execute(&amp;quot;Select и т.п...&amp;quot;,count). По идее после этого в переменной count должно храниться количество найденных записей, а у меня и тут &amp;quot;count=-1&amp;quot;. Мне кажется, что дело в старой версии Access, или вообще ADO как-то криво работает с базами Access. Например, запрос &amp;quot;select count(distinct column_name) as i from table_name&amp;quot; прекрасно работает с SQL Server и ни в какую с Access, в Access можно только &amp;quot;select count(*) as i from table_name&amp;quot;. Кстати из-за этого мне и понадобилось RecordCount, типаset rs=Con.execute(&amp;quot;select distinct c_name from t_name&amp;quot;)count=rs.RecordCountЕсли кто-то сталкивался с такой проблемой или знает решение, то подскажите пожалуйста, а то в цикле больно долго считает</description><pubDate>Wed, 06 Dec 2000 11:56:00 GMT</pubDate><dc:creator>Sergik</dc:creator></item><item><title>RE: RecordSet.RecordCount = -1</title><link>http://relib.com/forums/Topic702211-4-1.aspx</link><description>RecordCount будет работать только после того как сделаешь MoveLast. Так что либо сосчитать в цикле, либо выполнять дополнительный запрос &amp;quot;SELECT count(*) AS c FROM table1&amp;quot;</description><pubDate>Wed, 06 Dec 2000 11:16:00 GMT</pubDate><dc:creator>Alexey</dc:creator></item></channel></rss>