Hi eyal,<br>Write the select statement "select count(*) from table_name". and crete a recordset object with this statement. <br>This will give the count of records in the data base table.<br> or else<br>create a record set with the cursor type other than forward-only type. Use the select statement to access all the values from the table and use the recordset's recordcount property to get the no of records. If the value u got is -1, it means that the provider used to access the data base is not supporting the recordcount property. In this case you can use the earlier methid.<br><br>I can give you the code if you want
Hi,<br>First, thanks for your reply, since I'm new to ASP I'll appreciate you sending me the code so I can implement it in my code.<br>Thanks again,<br>Eyal
Hi,<br>Write the following code in the asp page.<br><%<br>set objconn = server.createobject("adodb.connection"<br>objconn.open "dsn=testdsn;uid=sa;pwd=;"<br>set objrec = server.createobject("adodb.recordset"<br>objrec.cursortype = adopenkeyset<br>strsql = "select * from table1"<br>objrec.open strsql,objconn<br>reccount = objrec.recordcount<br>response.write "No of records in the table=" & reccount & "<br>"<br>objrec.close<br>set objrec = nothing<br>objconn.close<br>set objrec = nothing<br>%><br><br>Before excuting this code create a system DSN. Follow these steps to create one.<br>From start --> settings --> control panel --> odbc data sources --> select System DSN<br>--> click add --> select the driver --> give DSN name as testdsn --> advanced button --> userid = sa and password keep empty --> select the data base --> click OK.<br>The steps to create a DSN will be different for different data bases. The above ones are for Access database.
Hi eyal,<br>here is the alternate code<br><%<br>set objconn = server.createobject("adodb.connection"<br>objconn.open "dsn=testdsn;uid=sa;pwd=;"<br>set objrec = server.createobject("adodb.recordset"<br>strsql = "select count(*) from table1"<br>objrec.open strsql,objconn<br>reccount = objrec(0)<br>response.write "No of records in the table=" & reccount & "<br>"<br>objrec.close<br>set objrec = nothing<br>objconn.close<br>set objrec = nothing<br>%>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.