Jump to content

Counting data in a DB


nekdonekje

Recommended Posts

How can I count the number of data in a DB?For example table1:name------- entry1entry2entry3entry4entry5entry6How to count the number of entrys?Tried the COUNT but it seems I must be doing something wrong:set i = MyConnection.Execute("SELECT Count('name') AS [Not Null] FROM table1;")response.write(i)

Link to comment
Share on other sites

set i = MyConnection.Execute("SELECT Count(name) AS Expr FROM table1")try without single quotes in name, butIf you could post the error, it will be easy.

I would do something like this .. <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("northwind.mdb"))set rs=Server.CreateObject("ADODB.recordset")sql="SELECT * FROM Customers"' you can change your sql statement based on a condition too !!!!rs.Open sql,conn i=rs.RecordCount response.write("The number of records is: " & i)rs.Closeconn.Close%>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...