Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script error from a user that claimed it to work

Posted on 2013-01-20
5
Medium Priority
?
287 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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

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 84

Expert Comment

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

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

730 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