Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is my recordset not working?

Status
Not open for further replies.

Riku

Programmer
Sep 2, 2001
119
I am using Access 97 database on a server that has asp and ADO support.
I created DSN database connection using FrontPage but my ASP connection don't work.

This is my code:
<body>
<%
Dim Con
Dim RS

'Sets your connection, I used a system DSN in this example
set Con = server.createobject(&quot;ADODB.Connection&quot;)
Con.open &quot;FILEDSN=persondatabase&quot;

'Name of your DSN
'Con = &quot;persondatabase&quot;

'Sets the RecordSet
Set RS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
'Your SQL string, this will generate the
' Defining the SQL string
SQLString = &quot;SELECT name FROM persons&quot;

'Open it all up
RS.Open SQLString,Con
%>

First name: <%=RS (&quot;name&quot;)%>
</body>
F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
Change
Con.open &quot;FILEDSN=persondatabase&quot;

to
Con.open &quot;DSN=persondatabase&quot;

hopefully that'll work

leo

 
i think u are using dsn connection thru odbc32bit connection.my advice is please avoid that way.Try it in dsnless connection
like this

dim dsn

dsn= &quot;DBQ=&quot; & Server.MapPath(&quot;db/egreetings.mdb&quot;) &&quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;

'please change ur database filename with mine and check where it exists in ur sever

set myconn=server.CreateObject(&quot;adodb.connection&quot;)

myconn.Open dsn

i hope this will help u

with regards
raghu
 
I disagree raghu. Depending on what database you are connecting to, a DSN less connection isn't always the best way to go. I find that when I'm connecting to SQL server I always use a System DSN to connect. Leo's correction should work.

G -GTM Solutions, Home of USITE-
-=
 
I used
dsn= &quot;DBQ=&quot; & Server.MapPath(&quot;db/egreetings.mdb&quot;) &&quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;

Code and no error appears BUT
When I add reference to recordset:
First name x: <%RS(&quot;name&quot;)%>
This will cause error

Error 500-100 - Internal Server Error - ASP Error
Internet Information Services
I have contacted the administrator of of the server where
our domain is at. I wonder could it be something wrong with our user wrights or something?
F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
Nope, you are not telling the code to do anything with RS(&quot;name&quot;), you need to use either = or response.write to get that value into the HTML, eg...

first name x: <%=RS(&quot;name&quot;)%>

G -GTM Solutions, Home of USITE-
-=
 
WOW !!
THANKS A LOT NOW IT WORKS.
My first database ASP page I ever created.
I have a lot experience with databases but not with ASP.
Now only the sky is the limit.

Thank again !!!!!
F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top