Click to See Complete Forum and Search --> : record set problem


jdsflash
05-16-2006, 11:13 AM
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



<%@ 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
%>

russell
05-16-2006, 01:57 PM
<%
Dim rstData2
Dim strConnection2
Dim cmd
Dim varSQL2
Dim strRDir
Dim strTemp

varSQL2 = "SELECT * FROM regflexo"
strConnection2 = "Provider=SQLOLEDB.1;Password=flexo;Persist Security Info=True;User ID=josh;Initial Catalog=RegFlex;Data Source=wisconline"
Set cmd = Server.CreateObject("ADODB.Command")
Set rstData2 = Server.CreateObject("ADODB.Recordset")

With cmd
.ActiveConnection = strConnection2
.CommandType = &H0001
.CommandText = varSQL2

rstData2.Open .Execute
End With

LoopCount = 1
If rstData2.EOF Then
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
LoopCount = LoopCount + 1
Response.Write("<li>" & rstData2("column1").Value & "<br>")
rstData2.MoveNext
Loop
Response.Write("</ol>")
End If

rstData2.Close
Set rstData2 = Nothing
Set cmd = Nothing
%>