Solved

Simple ADODB Recordset not working in Classic ASP

Posted on 2010-09-21
4
555 Views
Last Modified: 2012-05-10
I have a very simple web page in classic ASP. I'm reading some recordsets from a SQL db and displaying the results on an asp page. I am having a problem with all of the fields showing. The following fields show (from the code below): Title, webpagemessage, rowid. The following do not show: message and icon. This is very weird and I have run across this before but do not know a solution.
<%
dim myConnss2, myRS2

Set myConnss2 = Server.CreateObject("ADODB.Connection")
myConnss2.ConnectionString = "driver={SQL Server};server=srvffhiint;Address=srvffhiint,1433;Network=DBMSSOCN;uid=test;pwd=test;database=ffhintranet;"
myConnss2.open
%>
<html>

<head>
</head>

<body>
                              
<%
Set myRS2 = myConnss2.Execute("SELECT * FROM currenteventstest order by RowID desc;")

dim mymessage2
Do while not myRS2.eof

%>

<%=myRS2("title")%><br>
<%=myRS2("webpagemessage")%><br>
<%=myRS2("message")%><br>
<%=myRS2("rowid")%><br>
<%=myRS2("icon")%>

<%
myRS2.movenext
Loop
%> 
						                            
                 
</body>
</html>
<%
Set myRS2 = Nothing
myConnss2.close
%>

Open in new window

0
Comment
Question by:robertmayhue_iii
  • 2
4 Comments
 
LVL 3

Expert Comment

by:yourbudweiser
ID: 33728594
For sure those fields have data? Any errors on the page?
0
 

Author Comment

by:robertmayhue_iii
ID: 33728932
Those fields do have data and no errors.
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 250 total points
ID: 33729653
Can you give this a shot and see if it displays your records?

Carrzkiss
<%
dim myConnss2, myRS2

Set myConnss2 = Server.CreateObject("ADODB.Connection")
myConnss2.ConnectionString = "driver={SQL Server};server=srvffhiint;Address=srvffhiint,1433;Network=DBMSSOCN;uid=test;pwd=test;database=ffhintranet;"
myConnss2.open
%>
<html>

<head>
</head>

<body>
                              
<%


Set Mysql = Server.CreateObject("ADODB.Command")
Mysql.ActiveConnection=myConnss2
Mysql.Prepared = true
Mysql.commandtext="SELECT rowid, title, webpagemessage, message, icon FROM currenteventstest order by RowID desc"
Mysql.Parameters.Append sqlUser.CreateParameter("@username", adVarChar, adParamInput, 25, strmegaun) 
set myRS2 = Mysql.execute

Do while not myRS2.eof

%>

<%=myRS2("title")%><br>
<%=myRS2("webpagemessage")%><br>
<%=myRS2("message")%><br>
<%=myRS2("rowid")%><br>
<%=myRS2("icon")%>

<%
myRS2.movenext
Loop
%> 
						                            
                 
</body>
</html>
<%
Set myRS2 = Nothing
myConnss2.close
%>

Open in new window

0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33730772
In the code that I supplied above.
Remove line 22
Since you are not calling a Query, you do not need that line.
If you ever do need to do a Query, then please look at the article here.
http://www.experts-exchange.com/A_3626.html

This will show you everything that you need to know about running this type of code
And Running protected Queries against your database.

Good Luck and sorry for the extra un-needed line in the code.
Carrzkiss
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Want the count number from this QUery 2 54
Change visitor's REMOTE_ADDR to server's REMOTE_ADDR 2 38
Save ms data to server side. 19 55
CREATE DATABASE 3 28
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question