Solved

Simple ADODB Recordset not working in Classic ASP

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migrated SQL connection issues 2012 6 39
Determining if Request.Form is empty 1 46
ASP Focus problem 3 54
Get hold of longitude and latitude in iframe string 11 24
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

25 Experts available now in Live!

Get 1:1 Help Now