Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2006, 10:53 AM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jdsflash Send a message via Yahoo to jdsflash
Default recordset problem

Im attempting to build my first asp application. I cant seem to get past this first hump will someone point out what im doing wrong please.
Im getting this error:

ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed or invalid in this context.

/text.asp, line 10


Code:
<%@ Language=VBScript %>
<%
dim rstData2, strConnection2, cnData2, varSQL2, strRDir,strTemp
Set cnData2 = Server.CreateObject("ADODB.Connection") 
strConnection2 = "Driver={SQL Server}; server=wisconline;Database=RegFlex; UID=josh; PWD=flexo"
cnData2.Open strConnection2
DIM cn, rs, LoopCount
Set rstData2 = Server.CreateObject("ADODB.Recordset")
varSQL2 = "SELECT * FROM regflexo"
rstData2.Open varSQL2 
LoopCount = 1
If rstData2.EOF Then
    Write("something")
Else
    Write("<table border=0 width='100%' cellpadding=2 cellspacing=1 bgcolor=white>")
    Response.Write("<ol>")
    Do While Not rstData2.EOF ' Loop starts until end of recordset
        LoopCount = LoopCount + 1
        Response.Write("<li>" & rstData2("column1").Value & "<br>")        
        rstData2.MoveNext
    Loop
    Response.Write("</ol>")
End If
rstData2.Close
Set rstData2 = Nothing
cnData2.Close
Set cnData2 = Nothing
%>
 
Old May 16th, 2006, 11:49 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Got this code working.

I would suggest using the 'sa' account to get started since its one less thing you've got to worry about, database permissions.

You were also missing a "Response." in the first part of the "If" statement but since it looks like you had data in the table then you weren't going to get in there anyway.

Looks pretty good for a first start.

Code:
    dim rstData2, strConnection2, cnData2, varSQL2
    Set cnData2 = Server.CreateObject("ADODB.Connection") 
    strConnection2 = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=[servername];UID=sa;Password=[password];Database=[database name];"
    cnData2.Open strConnection2

    varSQL2 = "SELECT * from regoflex;"
    Set rstData2 = cnData2.Execute(varSQL2)
    If rstData2.EOF Then
        Response.Write("something")
    Else
        Response.Write("<table border=0 width='100%' cellpadding=2 cellspacing=1 bgcolor=white>")
        Response.Write("<ol>")
        Do While Not rstData2.EOF ' Loop starts until end of recordset
            Response.Write("<li>" & rstData2("column1").Value & "<br>")        
            rstData2.MoveNext
        Loop
        Response.Write("</ol>")
    End If
    rstData2.Close
    Set rstData2 = Nothing
    cnData2.Close
    Set cnData2 = Nothing







Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with recordset rwahdan BOOK: Access 2003 VBA Programmer's Reference 1 March 13th, 2008 05:03 AM
Recordset Problem hugoscp Classic ASP Professional 0 July 10th, 2007 05:59 AM
Problem In Recordset zaeem Classic ASP Databases 2 October 22nd, 2003 01:34 AM
Problem with recordset am_po_28 Pro VB 6 1 August 25th, 2003 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.