Here is question 1 answer, there is other ways though... and question 2 is below, although Im not sure if that is correct, but I think it is.
<%
Dim ConnString, strSQL
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("database.mdb"
' ADO connection class
set my_conn= Server.CreateObject("ADODB.Connection"
' rs recordset will contain all fields in db such as userID, name, email
set rs = Server.CreateObject("ADODB.RecordSet"
' Connect ADO & open database
my_conn.Open ConnString
strSQL = "SELECT COUNT(*) FROM table_name"
' Execute SQL statement
rs.open strSQL, my_conn
' Write out the number of records
Response.Write "There are <b>" & rs.Fields(0) & "</b> records in the database."
rs.close ' Close database connection
set rs = nothing 'obj variable released
%>
2
change your sql statement to:
strSQL = "SELECT COUNT(*) FROM table_name WHERE table_name NOT NULL"
Okay, I was told to do something similar... but instead of using Count(*) to use Count(ID) or something. What's the difference. And, if I want to use the data from the database as well, do I need to close the RS and open a new one? -Phil
fillup07@hotmail.com
Yes close it then open it, because you have to change the sql statement. As far as I know you can select which columns you want to count, but that doesnt really make since because if you are counting all records, why does it need to have a specific column?
If the format is like Count(ID, user_name, user_email) etc..
Then what's the difference what column or columns you put in there if they all return the total number of records???? Maybe I'm not understanding this correctly... -Phil
fillup07@hotmail.com
Thats exactly what I was saying, but thats the format of SQL... but nevermind that doesnt work, only one column name has to placed in the () or you can just use an astrick which is a wild card symbol. www.vzio.com
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.