Object doesn't support this property or method: 'EOF'
Hi,
Here is my code and I keep getting error -
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'EOF'
Can someone give me a clue as what is wrong with the my code below?
Thanks for your time
joe
------------------
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open("Provider=SQLOLEDB; Data Source=BUBBA\BUBBA; User Id = sa;
Password = test; Initial Catalog=Northwind")
Set cmdCust = Server.CreateObject("ADODB.Command")
Set rsCust = Server.CreateObject("ADODB.Recordset")
cmdCust.CommandText = "Select OrderID, OrderDate, RequiredDate, ShippedDate
from Orders"
cmdCust.CommandType = adCmdText
cmdCust.ActiveConnection = conn
rsCust = cmdCust.Execute
do while Not rsCust.EOF
Response.write(rsCust(0) & "-" & rsCust(1) & "-" & rsCust(2) & "-" &
rsCust(3))
rsCust.MoveNext
loop
rsCust.close
conn.close
cmdCust = Nothing
rsCust = Nothing
conn = Nothing
%>
</body>
</html>
Re: Object doesn't support this property or method: 'EOF'
Try "Set rsCust=cmd.Execute" (Set is missing from your code).
--
Patrice
"Joe" <Joe [at] discussions.microsoft.com> a écrit dans le message de news:
76008021-2294-4F4B-A621-303522167623 [at] microsoft.com...
> Hi,
>
> Here is my code and I keep getting error -
>
> Microsoft VBScript runtime error '800a01b6'
>
> Object doesn't support this property or method: 'EOF'
>
> Can someone give me a clue as what is wrong with the my code below?
>
> Thanks for your time
>
> joe
>
> ------------------
>
> <html>
> <body>
>
> <%
> set conn=Server.CreateObject("ADODB.Connection")
>
> conn.Open("Provider=SQLOLEDB; Data Source=BUBBA\BUBBA; User Id = sa;
> Password = test; Initial Catalog=Northwind")
>
> Set cmdCust = Server.CreateObject("ADODB.Command")
> Set rsCust = Server.CreateObject("ADODB.Recordset")
>
> cmdCust.CommandText = "Select OrderID, OrderDate, RequiredDate,
> ShippedDate
> from Orders"
> cmdCust.CommandType = adCmdText
>
> cmdCust.ActiveConnection = conn
>
> rsCust = cmdCust.Execute
>
> do while Not rsCust.EOF
> Response.write(rsCust(0) & "-" & rsCust(1) & "-" & rsCust(2) & "-" &
> rsCust(3))
> rsCust.MoveNext
> loop
>
>
> rsCust.close
> conn.close
> cmdCust = Nothing
> rsCust = Nothing
> conn = Nothing
>
> %>
> </body>
> </html>
>
>
Re: Object doesn't support this property or method: 'EOF'
Joe wrote:
<snip>
> conn.Open("Provider=SQLOLEDB; Data Source=BUBBA\BUBBA; User Id = sa;
> Password = test; Initial Catalog=Northwind")
sa?? Huge mistake. Do not use sa in application code. Create a sql login
with the minimum permissions required to perform the tasks needed by the
application and use that login. Guard the sa account as if your job
depended on it - it probably does. Hopefull you have not just posted the
real password for your sa account to the internet ....
<snip>
This line is not needed because you later redefine rsCust via the
cmdCust.Execute method
************************************************************ *******
> Set rsCust = Server.CreateObject("ADODB.Recordset")
************************************************************ *******
>
<snip>
>
> rsCust = cmdCust.Execute
>
In order to assign an object to a variable, vbscript requires the use of
the Set keyword. To clarify: the Execute method creates a recordset
(unless adExecuteNoRecords is used) and returns it to the caller which
can assign it to a variable. The line needs to be:
Set rsCust = cmdCust.Execute
Actually, you don't even need the Command object. The Connection object
has an Execute method which implicitly creates a Command object in the
background. Your code can be simplified to:
<%
option explicit
dim conn, rsCust
set conn=CreateObject("ADODB.Connection")
conn.Open("Provider=SQLOLEDB; Data Source=BUBBA\BUBBA; User Id = notsa;
Password = test; Initial Catalog=Northwind")
Set rsCust = conn.Execute(,,adCmdText)
do while Not rsCust.EOF
etc.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.