473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Simple query returns 0 records in asp, but all records in vbscript

I have a few vbscripts that I want to convert to asp pages so I can
use html to format the data better.

1). Do asp pages have to be run from an IIS server or can I just
create them locally and then open them in IE?

2) The following connection strings, accounts and queries work fine in
vbs files but I am getting 0 results when I run them as asp. I don't
know how to debug them to figure out the issue

here is the code

<%@ language="VBSCRIPT" %>
<html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 4.0">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>CFG site</title>
</head>
<body>

<%
Dim objConnection, dsn
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;Data Source=servername;" & _
"Trusted_Connection=Yes;Initial Catalog=edfcm4;" & _
"User ID=user;Password=password;"
Set rs=objConnection.Execute ("SELECT machine_name FROM
ecm_dat_machines")
%>
<table border="1">
<%
Do While Not rs.EOF
%>
<tr>
<td><%= rs.Fields("ecm_dat_machines.machine_name")%></td>
</tr>
<%
rs.MoveNext
Loop
%>
</table>
<%
Set objConnection = Nothing
%>
</body>
</html>

Nov 2 '06 #1
3 1512
<ma******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>I have a few vbscripts that I want to convert to asp pages so I can
use html to format the data better.

1). Do asp pages have to be run from an IIS server or can I just
create them locally and then open them in IE?

2) The following connection strings, accounts and queries work fine in
vbs files but I am getting 0 results when I run them as asp. I don't
know how to debug them to figure out the issue

here is the code

<%@ language="VBSCRIPT" %>
<html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 4.0">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>CFG site</title>
</head>
<body>

<%
Dim objConnection, dsn
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;Data Source=servername;" & _
"Trusted_Connection=Yes;Initial Catalog=edfcm4;" & _
"User ID=user;Password=password;"
Set rs=objConnection.Execute ("SELECT machine_name FROM
ecm_dat_machines")
%>
<table border="1">
<%
Do While Not rs.EOF
%>
<tr>
<td><%= rs.Fields("ecm_dat_machines.machine_name")%></td>
1. ASP pages must be run against an asp-enabled web server. If you have XP
Pro, you can add IIS 5.1 by going to Control Panel -Add Or Remove
Programs - Add/Remove Windows Components then ticking Internet Information
Services. If you open them in the browser directly, they are not processed
by the ASP engine, so the script will appear as text.

2. Wrong syntax. Try <%=rs("machine_name")%>. Don't include the table
name.

Couple of other things: you declared a variable called dsn, but never used
it. While you set the connection to nothing, you left the recordset alone.
You should close that and set it to nothing once you're done with it, too
(before finishing with the connection).

--
Mike Brind
Nov 2 '06 #2
wrote on 02 nov 2006 in microsoft.public.inetserver.asp.general:
1). Do asp pages have to be run from an IIS server or can I just
create them locally and then open them in IE?
ASP code only runs through the ASP interpretor, that converts output to a
html stream that is sent to the requesting browser.

Running an asp file in a browser will get you nowhere.
2) The following connection strings, accounts and queries work fine in
vbs files but I am getting 0 results when I run them as asp.
I strongly advice you against database handling trough ASP untill you have
mastered the concepts of ASP and it's script languages.
[Read the archive of this NG and the de facto faq http://www.aspfaq.com,
and a simple asp tutorial perhaps]
I don't
know how to debug them to figure out the issue
Basic debuging goes by inspecting error messages and putting

response.write yourVariableToBeRead
response.end

[vbscript version] breakpoints in strategic places.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Nov 2 '06 #3

<ma******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I have a few vbscripts that I want to convert to asp pages so I can
use html to format the data better.
Doesn't sound like ASP is what you need.

Continue to use VBS files. Research how to Automate IE to which you can
write the HTML output of the VBS. Here's a start for 10:-

Dim oIE : Set oIE = WScript.CreateObject("InternetExplorer.Application ")

oIE.menubar = false
oIE.toolbar = false
oIE.statusBar = false
oIE.navigate "about:blank"
oIE.visible = true

Do While oIE.Busy
WScript.sleep 100
Loop

Dim oDoc : Set oDoc = oIE.document

oDoc.open
oDoc.write "<html><body>Hello World</body></html>"
oDoc.close
For more advanced application you could consider creating a HTA.
Anthony.
Nov 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
4
by: PCL | last post by:
I am new to asp.net and am having a hard time with what i would usually do with a recordset. I have a simple query that returns a record - how can i get that record value into a variable after i...
7
by: DFS | last post by:
This UNION query is very slow. With only 3,000 records in the Parent table and 7,000 records in the Child table, it takes about 60 seconds to run and returns about 2200 records. Access 97. All...
3
by: Tom Mitchell | last post by:
All: I'm stumped on a query. How do I find duplicates in a table where one of the duplicates has values is a certain field and the other doesn't. For example, I have the following table: ...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
3
by: Bob C. | last post by:
When I migrated my tables to SQL Server I needed a way to overcome the slow performance of the Find method on my recordsets. Although this can be done by accessing the table directly using dao and...
2
by: Fendi Baba | last post by:
I created a person table with various fields such as Suffix, Salutation, etc, Some of these fields may not be mandatory for example suffix. In the actual table itself, I only have a field for...
5
by: GregO | last post by:
I am new to ASP and would like to know if anyone has a page that will display username, time, IP TIA - Grego
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.