Link to home
Start Free TrialLog in
Avatar of NadiaRashid
NadiaRashid

asked on

display specific excel cells in an html table - ALSO URGENT!!!!!!!!!!!

hi there

well this is the same page that i have my other urgent question based on. the component below is supposed to retrieve these 4 hgihlighted cells which i'l named : Priorities , and it's supposed to display them on the page that has the script in it...called genPri.asp. Now when i run the script i get errors either at :
                          rs.Open sql, cn,3,1
or
                         if rs(3) = "" or isnull(rs(3)) = "True" then
or
                         <td><%=rs(0)%></td>

the entire code snippet is below....now what am i doing wrong? and please ASAP help me out here! oh yeah another alternative would be to have those four cells displayed inside the page...now how would i go about doing that? please this is really urgent...supposed to present this on friday....please any suggestioons and elaboarated examples would be welcomed....THNAKS!

<html>
<head>
<%
  exceldb="PSDSS.xls"

' Create a server connection object
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "DBQ=" & Server.MapPath(exceldb) & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"


' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Query to run against the exceldb
' t_request is the name of the
' cell range as defined in excel
sql="select * from Priorities;"

' Execute the sql
rs.Open sql, cn,3,1
%>
<title>Generate Priorities</title>
</HEAD>

<BODY>
<form name="f1" method="post">
<table border="1" width="100%">
        <tr>
        <td width="22%"><P align=center><STRONG>Priority for P1</STRONG></P></td>
      <td width="22%"> <P align=center><STRONG>Priority for P2</STRONG></P></td>
      <td width="22%"> <P align=center><STRONG>Priority for P3</STRONG></P></td>
      <td width="22%"> <P align=center><STRONG>Priority for P4</STRONG></P> </td>
        </tr>

<%
if rs.Eof <> true then
response.write "<table border=1>"
while not rs.Eof
     if rs(3) = "" or isnull(rs(3)) = "True" then
    else
%>
     <tr>
            <td><%=rs(0)%></td>
            <td><%=rs(1)%></td>
             <td><%=rs(2)%></td>
            <td><%=rs(3)%></td>
       </tr>
<%
         
     end if
          rs.MoveNext
     
wend  
end if  
rs.Close
set rs=nothing
cn.Close
  %>
  </table>
  </form>
  </BODY>
  </HTML>
Avatar of Irwin Santos
Irwin Santos
Flag of United States of America image

Ok nadiarashid, I'm here..
we need the exact error....

insert the following into your code.. make sure that they are the FIRST & SECOND lines (place before <html> tag)
<% @ LANGUAGE = VBSCRIPT%>
<% Option Explicit %>

In Internet Explorer..go to TOOLS-INTERNET OPTIONS, ADVANCED tab, look for "SHOW FRIENDLY HTTP ERROR MESSAGES" and make sure  you UNCHECK the box.  Post the exact error message please.

Avatar of NadiaRashid
NadiaRashid

ASKER

morning irwin (if it's morning there)

here's the error i get :

Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/genPri.asp, line 50


where line 50 reads:      if rs(3) = "" or isnull(rs(3)) = "True" then

everything else is in order...all permissions granted...lemme know what u come up with
thanks irwin

nadia
that error says that it has access to the database the field/column name does NOT exist in your database OR it does exist, but you are using and incorrect variable in your coding

is "3" { in rs(3) } a fieldname/column or was the intention to use an array?

if you may consider replacing "3" with an alphanumeric name
the number 3 represents the last of the 4 cells i highlighted and assigned the name "Priorities" to in the excel file i'm calling. i've also tried calling it like this:

         rs("H42")
but it throws exactly the same error on that too

what do you mean alphanumberic name? should i assign a name to each individual cell then? then what about the SQL statment...will it stil be applicable?
nadia...ok screenshot this one...so I can see your worksheet.. upload to the board..
I would like to see your column/field names and part of your data

put it under this link
http://www.ctrlaltdel-usa.net/yabb_2_1_superman/YaBB.pl?board=Services
h42 has nothing inside..

perhaps use a static value
hey ya
just posted teh exact code...and moved the cells its supposed to call...the concept is...the first VBScript code enters values from the form in the previous page into specific cells...whhich affect all the other cells...and then output the final priorities generated
ASKER CERTIFIED SOLUTION
Avatar of Irwin Santos
Irwin Santos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi irwin...sorry for the half a day delay....

right so i assigned static values for the cells I42:I45 and i called them, it doesnt actually open the page......this is the error i get:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/test/genPri.asp, line 147

where line 147 reads:      if rs("I45") = "" or isnull(rs("I45")) = "True" then    

could it be that i have a conflict because i made 2 independent connections to excel in the same page?hould i consider displaying the cells in some other way? if so you have any suggestions?

thanx
nadia

hey ya...well i'm presenting my software today....so i made a make shift arraingement...and i'l work on this later....make shift as in embedding excel into html usgin ifarme...well thankx for ur hekp though!
"could it be that i have a conflict because i made 2 independent connections to excel in the same page?hould i consider displaying the cells in some other way? if so you have any suggestions?"

it is the I45 reference and defining that as a field/column....

Here is a Tutorial for you..

http://www.tutorialized.com/tutorial/Extract-data-from-Excel-Spreadsheet-using-ASP/9684