Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: database


Message #1 by "spencer" <solopress_@h...> on Mon, 23 Oct 2000 11:54:18 +0100
now i think the problem is with my  open recordset ???

Microsoft VBScript runtime error '800a01f4' 



Variable is undefined: 'rs' 



/myconnect1.asp, line 12 





<%Option Explicit%>

<!- -#include virtual="common/adovbs.inc" - ->

<% 

Dim objConn Dim objRS

set objConn = Server.Createobject ("ADODB.Connection") 

objConn.ConnectionString = "DSN=car"

objConn.Open 

%>

<HTML>

 <BODY>

<%

 Dim objRS

set objRS = Server.CreateObject("ADODB.recordset") 

objRS.Open " Peugeot206", objConn, , ,adcmdTable

%>











<TABLE border=1>



  <TR>



      <TD><B>(Description)</B>



      <TD><B>(Ukprice) </B>



      <TD><B>(Ourprice)  </B>



     



 </TR>

<%

         Do While not objRS.EOF 

         Response.Write "<TR><TD>" & objRS("Description")"</TD>"

         Response.Write "<TD>" & objRS("Ukprice")"</TD>"

         Response.Write "<TD>" & objRS("Ourprice")"</TD>"</TR>"

        objRS.Movenext

Loop

objRS.Close

Set objRS = Nothing

objConn.Close

Set objConn = Nothing

%>



 </TABLE>



</Body>

</HTML





Message #2 by "Ken Schaefer" <ken@a...> on Tue, 24 Oct 2000 11:45:26 +1000
> Dim objConn Dim objRS



Don't do this:

Do



Dim objConn, objRS



    - or -



' This is my preferred way

Dim objConn        ' As ADODB.Connection

Dim objRS            ' AS  ADODB.Recordset



Later on, you are doing another Dim for objRS, which you don't need. Dim all

your variables at the top of the page. (that should solve your problem)



Next, when using HTML tags,*always* delimit attibutes with " marks:



<table border="1">



OK? It will save you grief in the future when you start merging in database

records which have spaces in them.



Next hint is to move your database connection string into either an

application variable, or into an include. That way, if your database

changes, you only need to update a single line of code.



--- DBConnection.asp ---



<%

Dim strConnect

strConnect = "DSN=Car"

%>



--- OtherPage.asp ---



<%Option Explicit%>

<!-- #include virtual="/includes/DBConnection.asp" -->

<%

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open strConnect

%>



Last hint, move from ODBC to OLEDB if you can:

http://www.adOpenStatic.com/faq/whyOLEDB.asp



Cheers

Ken









----- Original Message -----

From: "spencer" <solopress_@h...>

To: "ASP Databases" <asp_databases@p...>

Sent: Monday, October 23, 2000 8:54 PM

Subject: [asp_databases] database





> now i think the problem is with my  open recordset ???

> Microsoft VBScript runtime error '800a01f4'

>

> Variable is undefined: 'rs'

>

> /myconnect1.asp, line 12

>

>

> <%Option Explicit%>

> <!- -#include virtual="common/adovbs.inc" - ->

> <%

> Dim objConn Dim objRS

> set objConn = Server.Createobject ("ADODB.Connection")

> objConn.ConnectionString = "DSN=car"

> objConn.Open

> %>

> <HTML>

>  <BODY>

> <%

>  Dim objRS

> set objRS = Server.CreateObject("ADODB.recordset")

> objRS.Open " Peugeot206", objConn, , ,adcmdTable

> %>

>

>

>

>

>

> <TABLE border=1>

>

>   <TR>

>

>       <TD><B>(Description)</B>

>

>       <TD><B>(Ukprice) </B>

>

>       <TD><B>(Ourprice)  </B>

>

>

>

>  </TR>

> <%

>          Do While not objRS.EOF

>          Response.Write "<TR><TD>" & objRS("Description")"</TD>"

>          Response.Write "<TD>" & objRS("Ukprice")"</TD>"

>          Response.Write "<TD>" & objRS("Ourprice")"</TD>"</TR>"

>         objRS.Movenext

> Loop

> objRS.Close

> Set objRS = Nothing

> objConn.Close

> Set objConn = Nothing

> %>

>

>  </TABLE>

>

>

> --- <BR>





Message #3 by "0 0" <solopress_@h...> on Tue, 24 Oct 2000 09:30:09 GMT

i would just like to thank you and include the comment that of all the 

advice and endless searching on the web for a solution this was the best and 

most clearest advice (excuse grammar). I actually understood it . Thankyou 

very much i have recommended this site to other people.





_________________________________________________________________________

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



Share information about yourself, create your own public profile at 

http://profiles.msn.com.




  Return to Index