Object doesn"t support this property or method: "EOF"
am 03.10.2006 15:25:02 von joe
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
------------------
<%
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
%>
Re: Object doesn"t support this property or method: "EOF"
am 03.10.2006 15:47:32 von Patrice
Try "Set rsCust=cmd.Execute" (Set is missing from your code).
--
Patrice
"Joe" a écrit dans le message de news:
76008021-2294-4F4B-A621-303522167623@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
>
> ------------------
>
>
>
>
> <%
> 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
>
> %>
>
>
>
>
Re: Object doesn"t support this property or method: "EOF"
am 03.10.2006 15:58:42 von reb01501
Joe wrote:
> 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 ....
This line is not needed because you later redefine rsCust via the
cmdCust.Execute method
************************************************************ *******
> Set rsCust = Server.CreateObject("ADODB.Recordset")
************************************************************ *******
>
>
> 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.