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!

viewing ASP pages--no dice still 2

Status
Not open for further replies.

crashc123

Technical User
Oct 3, 2001
80
US
I have installed IIS 5.0 on my machine. Have settings set for executables and scripts. Have named my database with a DSN ASP pages WILL NOT load. I even downloaded a lesson db file, set it up according to their instructions and put it in my folder, can view html pages, but no scripts. What's going on? How do I get these to run? Any Suggestions? Am I missing something, I thought that it was supposed to be easy to do.

By the way I even uninstalled and reinstalled my IIS.
Thanks for your input.

Sonya
 
Sonya,

Try something simple. Let's just see if the server will parse ASP.

Load this onto your server and run it.
Code:
<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
dim myName
myName = &quot;Hello, My name is Sonya.&quot;
Response.Write myName & &quot;<br>&quot; _
  & &quot;My host server is at: &quot; _
  & Request.ServerVariables(&quot;REMOTE_HOST&quot;)
%>

See what happens there. If that works, maybe you're not defining the server side script language at the top of the page properly.

ToddWW
 
Thank you ToddWW! Yours worked - Below is the part of the code I am trying to run. Hey as I was trying to open the page I acutally got a &quot;this page cannot be displayed&quot; message and at the bottom I got this:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/sie/projectslist.asp, line 12


<%@ Language=VBScript %>
<Html>
<Head>
<Title>Projects List<Title>
</Head>
<Body>
<% Response.Buffer = True %>
<%
Dim oRSpl
Set oRSpl= Server.CreateObject (&quot;ADODB.Recordset&quot;)
'open &quot;tablename&quot; and make sure the DNS is correct and on web server
oRSpl.Open &quot;Projects&quot;, &quot;DNS=SIEdata&quot;
'This is telling program to go to the first row.
oRSpl.MoveFirst


How do I fix this?
Thanks again for your help.
Sonya
 
OK, you've got a few problems here. The first one is an honest mistake and I'm not necessarily saying that this is the entire fix.

#1: You are specifying DNS. That stands for Domain Name Server which is a solution used for translating domain names to IP addresses. You need to use the term DSN which stands for Data Source Name and is more appropriate for connecting to databases.

#2: You're using the wrong syntax to open a recordset. And that's OK too. I'm going to show you how to do that here in a second, but first I want to see if we can get this DSN working so I just want you to run this code and let me know what happens.
Code:
<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
dim Conn
dim strProvider

strProvider = &quot;DSN=SIEdata&quot;

set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open strProvider

set Conn = Nothing
%>
Now if that returns a blank screen with no errors, then we're in luck. If you get an error, show that back here along with a few other pieces of information.

What database are you using ?
Is the database password protected ?
What is the physical path to the database on the server ?

Note: I would only ask that you to get in the habit of starting all of your ASP pages with those three lines at the very top.

ToddWW
 
That worked no errors just a blank page. I thought I was specifying the Data Source Name

Okay now what do I do?

I am running an MS Access database.
There are no passwords set up on the database. (This will be another project for another day.)

The physical path to the database is C:\Inetpub\
I have got ALOT to learn, but I am looking forward to it. Most of this is fun for me. And your help is SO appreciated.
 
OK, looks like we're making progress. Try this out.

Code:
<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
Dim strProvider
strProvider = &quot;DSN=SIEdata&quot;

Dim oRSpl
Dim strQuery
Set oRSpl= Server.CreateObject (&quot;ADODB.Recordset&quot;)
oRSpl.CursorType = 3
strQuery = &quot;SELECT * FROM projects&quot;
oRSpl.Open strQuery, strProvider
set oRSpl.ActiveConnection = Nothing
%>
<Html>
<Head>
<Title>Projects List<Title>
</Head>
<Body>
There are currently <%=oRSpl.RecordCount%> records in this table.
<%
set oRSpl = Nothing
%>
</Body>
</Html>
If that works, come back here and I'll give you a little step by step on creating recordsets, adding, deleting, and updating that database along with a great link to a reference book for you to buy on ASP. For the purpose of completing this particular page, when you reply, let me know what the name of the DB fields of the data that you want to display on the page are.

ToddWW
 
Okay I tried that. I got &quot;this page cannot be diplayed&quot; and:

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/test2.asp, line 14


Browser Type:
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Page:
GET /test2.asp

Time:
Wednesday, October 31, 2001, 2:57:42 PM


More information:
Microsoft Support

What does all that mean?

I have got the book &quot;Beginning ASP Databases&quot; from Wrox press and as you can probably tell I haven't read the whole thing--yet.
 
You're the 3rd person I've screwed up today because I was missing a line in the code. Try this. I forget to set the cursor location to the client with the oRSpl.CursorLocation = 3 command. Here you go.. My apologies.

<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
Dim strProvider
strProvider = &quot;DSN=SIEdata&quot;

Dim oRSpl
Dim strQuery
Set oRSpl= Server.CreateObject (&quot;ADODB.Recordset&quot;)
oRSpl.CursorType = 3
oRSpl.CursorLocation = 3
strQuery = &quot;SELECT * FROM projects&quot;
oRSpl.Open strQuery, strProvider
set oRSpl.ActiveConnection = Nothing
%>
<Html>
<Head>
<Title>Projects List<Title>
</Head>
<Body>
There are currently <%=oRSpl.RecordCount%> records in this table.
<%
set oRSpl = Nothing
%>
</Body>
</Html>


Should work like a charm.

Don't forget to reply back with the field names of the data you want displayed on the page so I can show you how to properly setup that recordset and display the data.

ToddWW
 
Woo Hoo!! I got a blank page with no error message. the fields in the table are:
ProjectID
ProjectName
ProjectDescription
ProjectBeginDate
ProjectEndDate
ProjectDeadLine
PlaneType
ClientID
 
Actually, you should have gotten a page that displays the following sentence..

There are currently X records in this table.

Did you not get that. If not, view the source of the blank page, is there anything there and if so, copy the source and paste it here. You do see that where I wrote that sentence in between the <body></body> tags of the page that I provided..

If you did get the sentence above, let me know. I need to know that your recordset is working error free before we go onto the next step.

ToddWW
 
Okay I got just a blamk whit page when I viewed by going (in IE 5.5) (my name is by default the name of the website). However when I viewed the source code I got the following:


<Html>
<Head>
<Title>Projects List<Title>
</Head>
<Body>
There are currently 5 records in this table.

</Body>
</Html>

(I do have 5 records in the table, also the title at the top of IE is still &quot; - Microsoft Internet Explorer&quot;)
 
OK, you've got a bad closing </title> tag. See that. You have two opening tags surrounding the title. Apparently IE doesn't like that !!

Also, my advice to you would be to change all of your HTML tags to lower case. You'll be happy you did if and when you start using sytles and CSS. Especially with Netscape who treats HTML tags with case sensitivity.

OK, I'll send over an example of displaying your data using that recordset. Should be just a few minutes.

ToddWW
 
OK, here you go.. Please look at this carefully so you can try to learn and understand the conventions used to display data from a database table. Also look at the source code when the page is rendered to the browser so you can see what ASP has sent to the browser.

Code:
<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
<%
Dim strProvider
strProvider = &quot;DSN=SIEdata&quot;

Dim oRSpl
Dim strQuery
Set oRSpl= Server.CreateObject (&quot;ADODB.Recordset&quot;)
oRSpl.CursorType = 3
oRSpl.CursorLocation = 3
strQuery = &quot;SELECT * FROM projects&quot;
oRSpl.Open strQuery, strProvider
set oRSpl.ActiveConnection = Nothing
%>
<html>
<head>
<title>Projects List</title>
</head>
<body>
<table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;>
  <tr>
    <td><b>ID</b></td>
    <td><b>Name</b></td>
    <td><b>Description</b></td>
    <td><b>BeginDate</b></td>
    <td><b>EndDate</b></td>
    <td><b>DeadLine</b></td>
    <td><b>PlaneType</b></td>
    <td><b>ClientID</b></td>
  </tr>
<%
oRSpl.MoveFirst
WHILE NOT oRSpl.EOF
%>
  <tr>
    <td><%=oRSpl(&quot;ProjectID&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectName&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectDescription&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectBeginDate&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectEndDate&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectDeadLine&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectPlaneType&quot;)%></td>  
    <td><%=oRSpl(&quot;ProjectClientID&quot;)%></td>  
  </tr>
<%
  oRSpl.MoveNext
WEND
oRSpl.Close
set oRSpl = Nothing
%>
</table>
</body>
</html>

ToddWW
 
Thank you!! I really appreciate your help. Works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top