Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating HTML table with ADO recordset 1

Status
Not open for further replies.

vza

Programmer
Aug 1, 2003
179
US
I am trying to create a Dynamic HTML page which queries an Oracle Database, placing its values within a HTML table. I have attempted to write code to perform this action but am running into problems. Any responses would be greatly appreciated. I am using an ADO Recordset to loop through DB. I recieve errors involving the Do...While...Loop:
Code:
<p align = &quot;center&quot;>
   <b> PI/GIS Validation Table <b> 
</p>
    
   <TABLE
        Id = &quot;PI_GISTable&quot;
	Align = &quot;center&quot; 
	Border = &quot;1&quot;
	Bordercolor = &quot;black&quot; 
	Cellpadding = &quot;2&quot; 
	Cellspacing = &quot;0&quot; 
	Width = &quot;500&quot;>
   <TBODY>
     <tr>
      <th align = &quot;middle&quot; Bordercolor = &quot;black&quot;> NTAG </th>
      <th align = &quot;middle&quot; Bordercolor = &quot;black&quot;>TAG /th>     
      <th align = &quot;middle&quot; Bordercolor = &quot;black&quot; > Descriptor </th>
      <th align = &quot;middle&quot; Bordercolor = &quot;black&quot; > Location </th>	
      <th align = &quot;middle&quot; Bordercolor = &quot;black&quot; > Point ID </th>	
     </tr>

      <Script Language = &quot;vbscript&quot;> Rs.Open &quot;Select * From PI_GIS&quot;,Cn </Script>
      <Script Language = &quot;vbscript&quot;> Do While Not RS.EOF </Script>
     <tr>		
	<td align = &quot;Center&quot;> <Script Language = &quot;vbscript&quot;> = Rs.Fields!NTAG </Script> </td>
	<td align = &quot;Center&quot;> <Script Language = &quot;vbscript&quot;> = Rs.Fields!TAG </Script> </td>
	<td align = &quot;Center&quot;> <Script Language = &quot;vbscript&quot;> = Rs.Fields!DESCRIPTOR </Script> </td>
	<td align = &quot;Center&quot;> <Script Language = &quot;vbscript&quot;> = Rs.Fields!LOCATION </Script> </td>
	<td align = &quot;Center&quot;> <Script Language = &quot;vbscript&quot;> = Rs.Fields!POINTID </Script> </td>
     </tr>
	<Script Language = &quot;vbscript&quot;> 
	        RS.MoveNext
		Loop
		Rs.Close
	</Script>
   </TBODY>
   </TABLE>

Thanks
-vza
 
Are you trying to do this server site or client side. right now your script is set up for client side.
if you want server side your script tags should look like
<script language=VBScript runat=server>
 
i was working on this at my PC so i think I want client side for now....

-vza
 
try something like this

<script language=&quot;vbscript&quot;>
set rs=createobject(&quot;ADODB.Recordset&quot;)
set cn=createobject(&quot;ADODB.Connection&quot;)
cn.open &quot;put your connection string here&quot;

</script>
<p align = &quot;center&quot;>
<b> PI/GIS Validation Table <b>
</p>

<TABLE
Id = &quot;PI_GISTable&quot;
Align = &quot;center&quot;
Border = &quot;1&quot;
Bordercolor = &quot;black&quot;
Cellpadding = &quot;2&quot;
Cellspacing = &quot;0&quot;
Width = &quot;500&quot;>
<TBODY>
<tr>
<th align = &quot;middle&quot; Bordercolor = &quot;black&quot;> NTAG </th>
<th align = &quot;middle&quot; Bordercolor = &quot;black&quot;>TAG /th>
<th align = &quot;middle&quot; Bordercolor = &quot;black&quot; > Descriptor </th>
<th align = &quot;middle&quot; Bordercolor = &quot;black&quot; > Location </th>
<th align = &quot;middle&quot; Bordercolor = &quot;black&quot; > Point ID </th>
</tr>

<Script Language = &quot;vbscript&quot;> &quot;Select * From PI_GIS&quot;,Cn </Script>
<Script Language = &quot;vbscript&quot;> Do While Not RS.EOF
strResult=strResult & &quot;<tr> <td align = 'Center'>&quot; & Rs.Fields(&quot;NTAG&quot;) & &quot;</td> </tr>&quot;


RS.MoveNext
loop
document.write Result</Script>
<tr>

</tr>
<Script Language = &quot;vbscript&quot;>
Rs.Close
set rs=nothing
set cn=nothing
</Script>
</TBODY>
</TABLE>
 
i appreciate all the help. I dont get any errors anymore, but now my page still no shows no table....Is the browser just skipping my code??

-vza
 
there is a type

if should be
document.write strResult
instead of
document.write Result
 
yeah i noticed that and fixed it earlier on...still no luck...

I really do appreciate all your help...

-vza
 
also looks like the rs.open did not copy over.
Did you fix that?

rs.open &quot;Select * From PI_GIS&quot;,Cn
 
yeah i fixed that as well
I also added Dim strResult
(i wasnt sure if that was necessary or not)
I see the header cells of the table, but nothing else.

-vza
 
check to see if you are actually getting records back from the database.
After your rs.open statement see if the recordset is at the eof

<Script Language = &quot;vbscript&quot;>
Rs.Open &quot;Select * From PI_GIS&quot;,Cn
document.write &quot;EOF:&quot; & rs.eof
</Script>
 
It says that it is true!!

-vza
 
That means the query is not returning any records back from the database. It will be false if you have records.
Check your database and connecion string to see why you are not getting any records.
What database are you using?
 
Oracle The table is populated with data....I will check the connection string....

Thanks for the help...i will be back tomorrow...I will let you know of my progress.

-vza
 
This is my ConnectionString...
' Create Connection Object to Oracle Database
Dim Cn
Dim strResult
' Establish/Set Connection Object
Set Cn = CreateObject(&quot;ADODB.Connection&quot;)
' Open DB Connection
Cn.Open &quot;Provider = MSDAORA.1; User ID =*; Password =**; Data Source = MyDS; Persist Security Info = False&quot;
' Create RecordSets
Dim Rs
' Establish/Set RecordSet Object
Set Rs = CreateObject(&quot;ADODB.Recordset&quot;)

I have used this ConnectionString within my previous VB Applications with no problem....plus wouldn't get a error when I tried to use my recordset if my ConnectionString was incorrect??

vbscript is very confusing to me....

-vza
 
Connection string looks good.
Check the table and see if your query brings back data.
 
Quote:
Set Cn = CreateObject(&quot;ADODB.Connection&quot;)
End Quote

Code:
<%
Set Cn = SERVER.CreateObject(&quot;ADODB.Connection&quot;)
Set Rs = SERVER.CreateObject(&quot;ADODB.Recordset&quot;)

%>

before <html> you can use
<OBJECT RUNAT=SERVER ID=cn PROGID=&quot;ADODB.Connection&quot;></OBJECT>
you dont have to write: 
Set Cn = SERVER.CreateObject(&quot;ADODB.Connection&quot;)


®od
 
server.createobject only works for server side code not client side code which is what vza said he was using
 
I think I figured it out...
i rearranged some of my code placing it in different HTML tags and my table was created. I was wondering if there was any way to make this table editable during runtime....

SarkMan appreciate the help....
Heres a star for your efforts.

-vza
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top