Hi everyone!
I'm trying to figure out how am I going to retrieve and display without duplicates, all records in my database. I'm using ASP. Anyone? Please help.
Hi DougCranston! Thank you for sparing your time. Sorry, I forgot to mention the database format that I'm using. You're right! It's MS ACCESS.
I tried using your code but it gave me this error message:
Error Type: ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/searchreso.asp, line 400
I looked at line 400, and it says:
<td><%=objRs("ResoTitle".Value%></td>
Correct me if I'm wrong but it appeared to me that field "ResoTitle" was not declared or defined properly in my SELECT statement.
My SELECT statement is this:
sql = "SELECT DISTINCT tblCat.ResoNum FROM tblCat "
Select Case Trim(LCase(Request("kind"))
Case "ordi": sql = sql & "ORDER BY OrdNum "
Case Else: sql = sql & "ORDER BY ResoNum "
End Select
'sql = sql & "ORDER BY tblCat.ResoNum "
'--Sort Order
Select Case Trim(LCase(Request("sortorder"))
Case "desc": sql = sql & "DESC;"
Case Else: sql = sql & "ASC;"
End Select
You can either go SELECT * .... and it will pull all of the fields or your SELECT statement needs to specify just what fields you want pulled back and available.
Your code only asks for tblCat.ResoNum, and as such it cannot find ResoTitle
The following is a sample of an SQL statement from one of my VBScript's. It is solely to show you that you can pull more than one field but selectively indicate only those you want and need. In my case I have over 35 fields in two tables in this DB, but I am pulling only 11 fields in the order I want/need them. Also, due to the length of the query I broke it up into multiple lines and I am concantenating them together for the query.
And it gave me the same result. It displayed all the records in the table including duplicates.
I tried replacing DISTINCTROW BY DISTINCT, but it gave me an error message like this:
Error Type:
Microsoft JET Database Engine (0x80040E57)
The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.
/searchreso.asp, line 124
Can you ship me a copy to look at. Willing to take a look at it, with no guarentees.
Select Distinct fieldname, fieldname, fieldname etc. will pull back UNIQUE records where ALL the requested fieldnames(contents really) are unique, not just the first one as I may have implied.
Select DistinctRow compares EVERY FIELD in a record to all others to ensure you have a unique record. If any field is slightly different it will be interpreted as a unique and distinct record.
My email address is douglas.cranston@verizon.com
Please zip it up, but don't make it a selfextracting file. Our system will not let those pass.
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.