nekdonekje Posted November 15, 2005 Share Posted November 15, 2005 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 More sharing options...
maelstorm Posted November 15, 2005 Share Posted November 15, 2005 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. Link to comment Share on other sites More sharing options...
kansasprog Posted November 15, 2005 Share Posted November 15, 2005 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.<{POST_SNAPBACK}> 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 More sharing options...
nekdonekje Posted November 16, 2005 Author Share Posted November 16, 2005 Works now, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now