Solved

Simple ADODB Recordset not working in Classic ASP

Posted on 2010-09-21
4
549 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now