|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I am trying to test a beginners piece of ASP scripting: <% @language=VBScript %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Author" content="Derek Robertson"> <meta name="GENERATOR" content="Mozilla/4.75 [en] (Win95; U) [Netscape]"> <title>Active Server Page 02</title> </head> <body> <center><b><font size=+1>ASP Test Page</font></b> <p><b><i>This page is one which will be built up to interact with an MS Access database</i></b></center> Output: <br> <% intS= 60*60 %> There are <% response.write intS %> seconds in an hour. </body> </html> Why won't MSN Explorer or Netscape 6.2 interpret the ASP scripting? They handle the HTML OK, but just throw the ASP scripting back at me. I don't seem to have any beginners luck on this one! Regards Derek Last edited by Derek Robertson : September 15th, 2002 at 07:42 AM. |
|
#2
|
|||
|
|||
|
Hi Dereck,
Netscape and Explorer don't interpret ASP code. Your web server has to do that. Do you have your web server set up to handle the ASP code? Also, make sure that your page is in a folder where the web server has access to. |
|
#3
|
|||
|
|||
|
Sounds to me, that your just running it off your hard drive and not on a server configured for asp. In order to run any server side language, you must have a server configured to run that language on. For asp, you would probally want to look at IIS, as a server, to run your scripts
|
|
#4
|
|||
|
|||
|
What about the use of Personal Web Server? I have got that running in the bacground, but not responding properly. Maybe there is a complication because I am running Windows ME, and had to download Personal Web Server to a different directory?
Last edited by Derek Robertson : August 30th, 2002 at 03:43 PM. |
|
#5
|
|||
|
|||
|
Hi Derek,
Did you install Option Pack 4 on your personal webserver? I am running PWS on a Win ME system without problems, ie can read ASP files. But in order for you to make it work download option pack 4: http://www.microsoft.com/ntserver/n...tPk/default.asp and install. Ensure your asp page is in a directory where PWs has access to and run the page using http://localhost/yourpage.asp Since asp is server side, your need to treat your computer as a webserver (which PWS does) You will see in your tray if PWS is running or not
__________________
- Rogier Doekes |
|
#6
|
|||
|
|||
|
Hi Rogier,
Thank you for your helpful response. I did download Option Pack 4 from the MSN site you quoted. Installation of OP4 kept giving various error messages, so I surfed about, and used the advice given by Mike Burgess at Microsoft MVP http://www.users.qwest.net/~careyh/fixes.htm >>QUOTE: Problem: How can I add PWS to windows ME? Possible Solution: From Mike Burgess, Microsoft MVP (How To Install PWS in Windows Me: http://members.home.net/winhelp98/pws.htm) Q266456 - Personal Web Server Is Not Included with Windows Millennium Edition http://support.microsoft.com/suppor...s/Q266/4/56.asp Use the patch from this Microsoft Knowledgebase Article first: Error Message: An Unknown Error Occurred While Making MTS Specific Changes to the System Registry http://support.microsoft.com/suppor...s/Q246/0/81.ASP Install PWS IN custom MODE and ONLY install Transaction Server, SETUP will prompt you, that other components are needed. Get it down to basically just Transaction Server, core components and MDAC. Reboot and then run Setup again via Add/Remove and install the other components. (Personal Web Server, etc..) If you already have PWS installed, try removing everything via Add/Remove but Transaction Server then reboot. Run Setup again to add the rest. >>UNQUOTE After getting PWS installed successfully, the present situation is that I have a PWS icon in my system tray, and it shows "Personal Web Server is running" Your point about: Ensure your asp page is in a directory where PWs has access to and run the page using http://localhost/yourpage.asp seems to be my current problem. The file I am trying to test resides in my c:\inetpub\wwwroot\dmrweb and it has a filename with a ".html" file extension. How do I get PWS to test that file? Thanks again Regards Derek |
|
#7
|
|||
|
|||
|
try to save the file with a .asp extension and run it again using
http://localhost/drwweb/yourfile.asp Also ensure your properties are setup right: - dubble click on the PWS icon in your tray - click Advanced - Click Edit Properties - verify the directory (and the wwwroot directory) has read and scripts access Then it should work. success |
|
#8
|
|||
|
|||
|
Quote:
lol iis 5 or apache with the asp module would help you see your asp scripts as other's have mentioned this ![]()
__________________
Apache Expert |
|
#9
|
|||
|
|||
|
Hi asp_man,
See above: ASP runs server side. this means you need to configure your computer as a server. See abow how to download option pack 4 for PWS. You need this to run asp files. Which browser you use does not matter, again, since asp runs server side. see here a tutorial on beginning with ASP: http://www.devguru.com/features/tutorials/ASP/ASP.html |
|
#10
|
|||
|
|||
|
Thanks to all contributors,
I have now got some simple ASP working, and I want to move on to using ASP to go to an Access 2000 database, which is parked in my c:\inetpub\databases At this stage I need to be sure that I understand fully the personalised pieces of the tutorial line: DataConn.Open "DSN=dsnname;SRVR=server IP address;UID=username;PWD=password" For dsnname I put myfile.mdb For server IP address I put c:\inetpub\databases In ODBC Data Sources > System DSN > Name I added myfile.mdb and left Description blank also under Advanced I left Default Authorisation blank On trying to test myfile.asp I get the message: Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified What do I need to do now please? Regards Derek |
|
#11
|
|||
|
|||
|
Hi Derek
The tutorial you read speaks of a DSN, which is a ODBC connection. ODBC stands for Open DataBase Connection, which is microsoft way of handling connections to databases. DSN less connection also exist, but that's another matter. What you need to do: 1. Go Start/ settings/Control Panel/ODBC Data Source 2. Go to the tab System DSN 3. Click Add.. 4. Select the Access Driver and click Finish 5. Under Data Source Name enter a name 6. Desciption is for reference 7. Click Select and select the database 8. After OK, your DSN is ready Now in your ASP connection string you reference the name you gave under point 5: cnn.Open "dsn=see_5;Uid=;Pwd=" success -Rogier |
|
#12
|
|||
|
|||
|
Thanks Rogier,
Having done as you suggested, I now get no error messages. Now we come to pulling information from the database. Line 1 of the 4 lines discussed in the tutorial: StrSQL = "SELECT * from TABLE" I substituted mytablename in place of TABLE Line 4 of 4 in tutorial: Set TABLE = DataConn.Execute(strSQL) I substituted mytablename in place of TABLE Is the case of the "s" in str important? Line 1 in the tutorial uses "StrSQL" and Line 4 uses "strSQL" I got no information from the TABLE. Regards Derek |
|
#13
|
|||
|
|||
|
option explicit
VBscript is a weak typed language, meaning that all your variables can be of any type.
However, it is a good programming habit to start each asp file with the following snippet: <% Option Explicit%> This means that you explicitely have to define your variables: you do this with the Dim statement So this is correct programming: Dim oCnn, strSQL Set oCnn = Ser........ strSQL = "Select......" If you type now oCnn.Execute (sql) you will get an error message saying that variable sql is not defined, which is good, since you would like to use strSQL.. see http://www.devguru.com/Technologies...ickref/dim.html -Rogier |
|
#14
|
|||
|
|||
|
Hi Rogier,
I have tried the Option Explicit advice. I have now first success in getting information from my database, in that the first record is output OK. But I cannot get the Do....Loop to retrieve subsequent records to EOF. The contents of my test file are currently: <% @language=VBScript %> <!-- Option Explicit --> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Author" content="Derek Robertson"> <meta name="GENERATOR" content="Mozilla/4.75 [en] (Win95; U) [Netscape]"> <title>ASP Test SQL</title></head> <body> <% Dim DataConn, StrSQL %> <% Set DataConn = Server.CreateObject("ADODB.Connection") %> <% StrSQL = "SELECT * from icon_database" %> <% DataConn.Open "DSN=icon-ps_trial;UID=;PWD=" %> <% icon_database = DataConn.Execute(StrSQL) %> <% Do Until icon_database.EOF %> <br><br><% response.write icon_database ("id") %> <br><br><% response.write icon_database ("pkey") %> <br><br><% response.write icon_database ("title") %> <br><br><% response.write icon_database ("refno") %> <br><br><% response.write icon_database ("description") %> <br><br><% response.write icon_database ("start") %> <br><br><% response.write icon_database ("location") %> <br><br><% response.write icon_database ("category") %> <br><br><% response.write icon_database ("salary") %> <% icon_database.MoveNext Loop %> </body> </html> I get two error messages: For start of Do Loop: Microsoft VBScript runtime error '800a01b6' Object doesn't support this property or method: 'EOF' For increments to next record: Microsoft VBScript runtime error '800a01b6' Object doesn't support this property or method: 'MoveNext' How do I get the Do....Loop to work? Regards Derek Last edited by Derek Robertson : September 14th, 2002 at 02:08 AM. |
|
#15
|
|||
|
|||
|
Re: Communicating with an Access Database
Hello Derk...
You have made your code very complex... You must use i.e. <% statements statements statements %> you must use while loop... i think it would work fine.... i.e. while not icon_database.eof statements statements statemetns wend i dont know what the problem... database access is so simple... <html><head><% strConnect = ----your connection string----%> </head><body> <% dim objRS set objRS = server.createobject("ADODB.REcordset") objRS.open "TableName", strConnect while not objrs.eof response.write objRS("field1") response.write objRS("Field2") -------- -------- objRS.MoveNext wend objRS.close set objrS=nothing %> |