Link to home
Start Free TrialLog in
Avatar of Aencinger1
Aencinger1

asked on

Pulling information out of an Microsoft ACESSS Database and displaying the information on a webpage.

Im having trouble getting this to work, and honestly I dont know where to really start on this, I want to pull product information out of a database and display it on a webpage using asp, but I get error messages and to be honest I dont know where to start or if im even doing it right. TO get a better IDEA of my problem goto  Http://www.rhjgold.com, click on the wax catalog button and then click on the diamond fashion button,  I want to pull all products in that database out, and display them.  here is the code and the error messages im getting.

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/dfashionwax.asp, line 8

Invalid class string




Here is the code:

<%
 ' open database connection
set db1 = Server.CreateObject("ADODB.Connection")
'    db1.Open "DSN=DB2094a;UID=*****;PWD=*****"
' open recordset

' open Recordset
Set RS = Server.CreateObject( "ADODB.Recordest" )
RS.ActiveConnection = db1
RS.Open "SELECT * FROM diamondfashion"

' loop through Recordset
WHILE NOT RS.EOF

Response.Write RS( "product_name" )
RS.MoveNext
WEND

%>
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

>>Set RS = Server.CreateObject( "ADODB.Recordest" )

typo?? try this instead:

Set RS = Server.CreateObject( "ADODB.Recordset" )
ASKER CERTIFIED SOLUTION
Avatar of apresto
apresto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aencinger1
Aencinger1

ASKER

ok, im really close to makeing this work now... after entering all the information in the selected spots, I now only get the following error.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.


I think I must have something wrong in here, this is the new code:

<%
'Declare your variables
Dim strDB, conn, strcon, rs  

'Set database path variable
strDB = "fpdb/njbatabase.mdb"

'Set a variable called Conn as your connection variable
Set Conn = Server.CreateObject( "ADODB.Connection" )

'Set up your Database drivers
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=*****;pwd=*****; DSN=DB2094A; DBQ=" & Server.MapPath(strDB)

'Open the database connection
Conn.Open strCon

'Now to get your info into a recordset and display it
'Tell the page that the variable called rs will be a recordset
Set rs = server.createobject("ADODB.recordset")

'Store info from the database in the recordset - Always remember to put the connection variable at the end of these (conn)
rs.open "SELECT * FROM diamondfashion", conn
   
IF not rs.eof Then                                                        'IF the SELECT picked up info THEN
     While not rs.eof                                                      'WHILE the recordset is NOT EMPTY
        response.write rs("product_name") & "<BR>"                       'TYPE THE FIRST PRODUCT_NAME and line break
      rs.movenext                                                          'Move to the next record
    Wend                                                                     'End the WHILE loop when there are no more records
Else                                                                           'IF the SELECT did NOT PICK UP INFO THEN
    Response.write "There are no procucts to display"     'Write this to the screen
End If                                                                        'END IF


%>

Are you still having tha problem.  what line does this error point to :

[Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.

Thanks for the points and grade :o)
I think its your database driver, you may need to change to OLEDB:

http://www.frontpagewebmaster.com/m-10783/tm.htm

http://www.tek-tips.com/viewthread.cfm?qid=943424&page=6

These are some references i found that may help, if they do not let me know.  But this is assuming the error points to this line:

Conn.Open strCon
Ok, I found that the database I was trying to connect to did not have a username or password set, I got that fixed and now it appears that it is connecting to the database because it now gives me this error message:

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal

I have checked everything six times, all the names are spelled correctly and its pointing to the right database.  I have checked the fields twice and checked the spelling twice.  Now im at a lost it says error on line 26 which appears to be:

 response.write rs("product_name") & "<BR>"                       'TYPE THE FIRST PRODUCT_NAME and line break

Any other help you could give me would be greatly appriciated.

Thank You
Huum... Well normally this error:

Item cannot be found in the collection corresponding to the requested name or ordinal

Means that either the recordset is empty or the name of the field is wrong...

So you are sure that the field in the database is called product_name and not product name - no spaces

if this doesnt work, try storing rs("product_name") in a variable and calling that:

Dim Prod_name
Prod_name = rs("Product_name")

...


response.write Prod_Name & "<BR>"

Just to see if the error changes line
>>Item cannot be found in the collection corresponding to the requested name or ordinal
Make sure the "product_name" is selected from your statement query ?

you can try to debug it by putting a loop like:

for i = 0 to rs.fields.count - 1
   response.write rs.fields(i).name & "<br>"
next

but you can directly check that from your sql statement as well.
if that doesnt work whats does your diamondfashion table look like, if you could respond with the names of the fields that would be great.  Just to be sure.

Bu i think tyancs suggestion will work
*ryancys