?
Solved

Can't get classic asp connection to work with sql server 2005

Posted on 2008-10-13
4
Medium Priority
?
317 Views
Last Modified: 2012-05-05
I'm trying to connect an asp page to a sql server 2005 database.  The asp page is on an IIS server, on two different servers.  This is not an express edition.

I've been able to connect to the database from a php page on an apache2 server, but now I need the IIS to connect, and can't get it to work.  When I open the page, I don't get any errors, or anything to display, just a blank page.  

Also, since I don't know ASP, I don't know if its the code, or the connection that isn't working.  There is data in the database, I've taken the php page that works, and using that to try and make an asp page.
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
mserver="server.domain.edu"
dbName="database"
UserID_db="user"
PassWD="password"
strCon="Provider=SQLOLEDB.1;Data Source=" & mServer & ";Initial Catalog=" & _
  dbName & ";User ID=" & UserID_db & ";Password=" & PassWD & ";"
Conn.Open strCon
sSQL = "SELECT * FROM myNorthwest_Links1 ORDER BY links_ID ASC"
Set Rs = Conn.Execute(sSQL)
Do While NOT Rs.EOF
Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
%>

Open in new window

0
Comment
Question by:baumli1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 22705351
You're not doing anything w/ your retrieved data:

Do While NOT Rs.EOF
  Response.write rs.fields(0).value & "<br>"
Rs.MoveNext
Loop

Open in new window

0
 

Author Comment

by:baumli1
ID: 22705903
Added that in, and no change, still a blank page.  How can I display error messages so I can at least see if I am getting the connection to work?
0
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 22706192
I'm trying to remember if this works in classic ASP ... it would in VB6 ...


<%
On Error Goto Err_Handler
 
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
mserver="server.domain.edu"
dbName="database"
UserID_db="user"
PassWD="password"
strCon="Provider=SQLOLEDB.1;Data Source=" & mServer & ";Initial Catalog=" & _
  dbName & ";User ID=" & UserID_db & ";Password=" & PassWD & ";"
Conn.Open strCon
sSQL = "SELECT * FROM myNorthwest_Links1 ORDER BY links_ID ASC"
Set Rs = Conn.Execute(sSQL)
Do While NOT Rs.EOF
  Response.write rs.fields(0).value & "<br>"
 
Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
 
Goto NoError
 
Err_Handler:
  Response.write "ERROR " & err.number & ": " & err.Description
NoError:
%>

Open in new window

0
 

Author Comment

by:baumli1
ID: 22706291
Yes, the first response was the correct one.  I am using a cms that was giving a template to the page, the asp had no template matching sections, so nothing was displaying.  Once I told the cms to not apply a template, and add in the Response.write statement in the loop it worked.  Thanks for the help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 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