Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Simple query returns 0 records in asp, but all records in vbscript

Reply
Thread Tools

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

 
 
masg0013@gmail.com
Guest
Posts: n/a
 
      11-02-2006
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>

 
Reply With Quote
 
 
 
 
Mike Brind
Guest
Posts: n/a
 
      11-02-2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      11-02-2006
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)
 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      11-02-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
db query returns many records Andrew Poulos Javascript 0 07-09-2007 10:39 PM
Creating DNS Reverse Lookup zones, and PTR records using VBScript and WMI Rahul Apte ASP General 0 04-27-2004 11:43 AM
Query AD using ASP.Net(C#) fails but works in VBScript M. Craig ASP .Net 2 11-19-2003 12:36 AM



Advertisments