关于网友提出的“ vc中sql语句的select问题”问题疑问,本网通过在网上对“ vc中sql语句的select问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: vc中sql语句的select问题描述:
VCaccess
CString SQL;SQL="SELECT * FROM SumDb WHERE Figure2='3' ";
Sumset.Open(AFX_DAO_USE_DEFAULT_TYPE,SQL)
如何判断select结果是否为空?
解决方案1:
dao确实很不怎么滴,还是使用ado
实际上,数据库最方便的环境还是VB,速度基本上也不会比VC逊色。其实数据的传输都是通过ole借口,都是通过虚表绑定,速度差别不大,但VC的类型转换,令人一个头两个大 解决方案2:
CDaoRecordset::GetRecordCount
long GetRecordCount( );
throw( CDaoException, CMemoryException );
Return Value
Returns the number of records accessed in a recordset object.
Remarks
Call this member function to find out how many records in a recordset have been accessed. GetRecordCount does not indicate how many records are contained in a dynaset-type or snapshot-type recordset until all records have been accessed. This member function call may take a significant amount of time to complete.
Once the last record has been accessed, the return value indicates the total number of undeleted records in the recordset. To force the last record to be accessed, call the MoveLast or FindLast member function for the recordset. You can also use a SQL Count to determine the approximate number of records your query will return.
As your application deletes records in a dynaset-type recordset, the return value of GetRecordCount decreases. However, records deleted by other users are not reflected by GetRecordCount until the current record is positioned to a deleted record. If you execute a transaction that affects the record count and subsequently roll back the transaction, GetRecordCount will not reflect the actual number of remaining records.
The value of GetRecordCount from a snapshot-type recordset is not affected by changes in the underlying tables.
The value of GetRecordCount from a table-type recordset reflects the approximate number of records in the table and is affected immediately as table records are added and deleted.
A recordset with no records returns a value of 0. When working with attached tables or ODBC databases, GetRecordCount always returns – 1. Calling the Requery member function on a recordset resets the value of GetRecordCount just as if the query were re-executed.
For more information about navigating in recordsets, see the articleDAO Recordset: Recordset Navigation in Visual C++ Programmer's Guide. For related information, see the topic "RecordCount Property" in DAO Help.
CDaoRecordset Overview | Class Members | Hierarchy Chart
See Also CDaoRecordset::GetFieldCount, CDaoRecordset::GetFieldInfo, CDaoRecordset::GetIndexCount, CDaoRecordset::GetIndexInfo