Solved

Script error from a user that claimed it to work

Posted on 2013-01-20
5
285 Views
Last Modified: 2013-11-19
Hi.

I have a problem with web page for retrieving data from an access database.
The original post claimed it was working, but I only get the first record and it doesn't refresh when I use the combo-box to retrieve new data.

To me it seems to be the where clasue that isn't working. I get the correct data from the request.querystring statement, but it only returns the data from the first record in the database. The original post was ID: 20443483.

My code is as follows:

<%response.buffer=true%>
<%

Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:/inetpub/db/dbimgs21.accdb;Persist Security Info=False"
'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:/inetpub/db/dbimgs21.accdb;Mode=Read|Share Deny None;Persist Security Info=False

set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM Table1"
rs.Open sql, oConnection

%>
<html>
<head>
<title>My plants</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1253">
</head>
<script language="Javascript">
function doSel(obj)
{
  for (i = 0; i < obj.length; i++)
     if (obj[i].selected == true)
       eval(obj[i].value);
}

</script>
<body>
<select name="Ref_ID" onchange="doSel(this)">
<option value="">Vennligst velg en art</option>
<%Do while not(rs.eof)%>
<option value="location.href='dropdown.asp?id=<%=rs("ID")%>'" <%if request.querystring("id")=rs("ID") then response.write "selected" end if%>><%=rs("ID")%></option>
<%
rs.movenext
loop
%>
</select>

<%if request.querystring("id") <> "" then
set rs1 = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * FROM Table1 WHERE ID = '"& request.querystring("id") &"'"
rs1.Open sql, oConnection

%>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
   <td>City</td>
    <td> 
<input type="text" name="txtcity" value="<%=rs1("City")%>">
    </td>
 </tr>
 <tr>
   <td>State</td>
   <td>
      <input type="text" name="txtstate" value="<%=rs1("State")%>">
    </td>
 </tr>
</table>
<%rs1.Close()
Set rs1 = Nothing
end if
%>

<%
rs.Close()
%>
</body>

</html>

Open in new window

0
Comment
Question by:Evert Jor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 38798902
Lines 40 and 41 were wrong.

<%response.buffer=true%>
<%

Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:/inetpub/db/dbimgs21.accdb;Persist Security Info=False"
'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:/inetpub/db/dbimgs21.accdb;Mode=Read|Share Deny None;Persist Security Info=False

set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM Table1"
rs.Open sql, oConnection

%>
<html>
<head>
<title>My plants</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1253">
</head>
<script language="Javascript">
function doSel(obj)
{
  for (i = 0; i < obj.length; i++)
     if (obj[i].selected == true)
       eval(obj[i].value);
}

</script>
<body>
<select name="Ref_ID" onchange="doSel(this)">
<option value="">Vennligst velg en art</option>
<%Do while not(rs.eof)%>
<option value="location.href='dropdown.asp?id=<%=rs("ID")%>'" <%if request.querystring("id")=rs("ID") then response.write "selected" end if%>><%=rs("ID")%></option>
<%
rs.movenext
loop
%>
</select>

<%if request.querystring("id") <> "" then
set rs1 = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * FROM Table1 WHERE ID = "& request.querystring("id")
rs1.Open sql2, oConnection

%>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
   <td>City</td>
    <td> 
<input type="text" name="txtcity" value="<%=rs1("City")%>">
    </td>
 </tr>
 <tr>
   <td>State</td>
   <td>
      <input type="text" name="txtstate" value="<%=rs1("State")%>">
    </td>
 </tr>
</table>
<%rs1.Close()
Set rs1 = Nothing
end if
%>

<%
rs.Close()
%>
</body>

</html>

Open in new window

0
 

Author Comment

by:Evert Jor
ID: 38802132
Thanks DaveBaldwin.

This works on a single page, but when I try to use "include" statements it doesn't.
I've reviewed several posts regarding this issue. According to Microsoft the following should work:
"To work around this issue, use one of the following methods.
Method 1: Use the #include virtual statement together with an absolute file path

To work around this issue, use the #include virtual statement together with an absolute file path in the Test.asp Web page. Consider the following code examples:
The following line of code does not work.
<!-- #include virtual ="../Date.asp" -->
The follow line of code works.
<!-- #include virtual ="Samples/Includes/Date.asp" -->
Method 2: Use the #include file statement together with a relative file path

To work around this issue, use the #include file statement together with a relative file path in the Test.asp Web page. Consider the following code samples:
The following line of code does not work.
<!-- #include virtual ="../Date.asp" -->
The following line of code does work.
<!-- #include file ="..\Date.asp -->
Note By default, parent paths are disabled in IIS 6. To enable parent paths, you must manually set the AspEnableParentPaths property in the metabase to TRUE."

However it doesn't.

I get error |ASP_0126|Cannot_find_the_include_file

Any ideas what may be wrong?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38802313
Ok, that's confusing.  What you posted is a 'complete' though poorly formatted page.  What do include statements of any kind have to do with it?  What are you trying to do?
0
 

Author Comment

by:Evert Jor
ID: 38804932
Hi.

I was trying to include the dropdown.asp page in another main.asp page.

Now I figured out what was wrong: Line 31 in the code have to point to the main page.
Thanks for your help!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38806631
You're welcome, thanks for the points.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question