PDA

View Full Version : dropdown box search


Greg
08-31-2004, 06:20 AM
The following page stopped working when I had to stop using the mappath connection line any suggesting from anybody? I had to stop using mappath connection because we went to a paid server from using a free server.

I need to use something like Data Source=\\premfs15\sites\Premium15\troop230\database\track.mdb"%> Now mind you, I got this code maybe a few years ago from
Abakada and it worked good with the mappath connection line, also beaware that its using
a include file......If you have a better way i am willing to change the whole code, but I am not that good at asp :smack: so any help you give me you gonna have to almost draw me a picture like give me the code line for line, I would be very appreciated if someone could help me get a page like this going again....thanks in advance for anyone looking at this.


<%@ language="VBScript" %>
<!-- #include file="adovbs.inc" -->
<html>
<head>
<title>Scout Lists</title>
<!-- ©2000 Abakada Web WorkShop; Author: Rey V. Nuñez -->
<link href="tutor.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
select {width:125}
-->
</style>
<% 'specify the provider
'strProvider="driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("\troop230\db\scout.mdb") & ";"
'create and open a connection
set dbConn = Server.CreateObject("ADODB.Connection")
'dbConn.Open strProvider
dbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;"_
& "Data Source=\\premfs15\sites\Premium15\troop230\database\track.mdb"%>

</head>

<body bgcolor ="#009999">
<div align="center">
<h3>Pick a Scout</h3>
<% rowCount=0
'create and open the products recordset
strQuery = "SELECT fname, rank, patrol, position, work FROM scout"
set rsProds=Server.CreateObject("ADODB.Recordset")
rsProds.Open strQuery, dbConn, , , adCmdText
'define the options query
strSQL="SELECT DISTINCT fname FROM scout"
'create and open the options recordset
set rsType=Server.CreateObject("ADODB.Recordset")
rsType.Open strSQL, dbConn, , , adCmdText %>
<form method="post">
Choose A Group <select name="fname">
<% do until rsType.EOF %>
<option><%= rsType("fname")%>
<% rsType.MoveNext
loop
'close options recset and flush from memory
rsType.Close
set rsType = Nothing %>
</select> <input type="submit" value="Show me">
</form>
<% if not isEmpty(Request("fname")) then
strType=Request("fname") %>
<h5>. . . retrieving <%= strType %> records for your question</h5>
<% 'filter the products query
rsProds.Filter = "fname = '" & strType & "'" %>
<table width=90% cellspacing=1 cellpadding=5 border=0>
<!-- begin column headers for Products table -->
<tr>
<th>Scout</th>
<th>Rank</th>
<th>Patrol</th>
<th>Position</th>
<th>Work</th></tr>
<% 'cycle thru the record set and display each row results
do until rsProds.EOF %>
<tr>
<td align="right"><%= rsProds("fname")%></td>
<td align="right"><%= rsProds("rank")%></td>
<td align="right"><%= rsProds("patrol")%></td>
<td align="right"><%= rsProds("position")%></td>
<td align="right"><%= rsProds("work")%></td></tr>
<!-- next Row = next Record -->
<% rowCount = rowCount+1
'increment record position with MoveNext method
rsProds.MoveNext
loop
'close connection and flush objects from memory
dbConn.Close
set dbConn = Nothing
set rsProds = Nothing %>
</table>
<% end if %>
</div>
<br>
<br>
<br>
</center>
<style type="text/css">
<!--
.Navlink {COLOR: #Black; TEXT-DECORATION: none; font-family: arial; font-size: 12pt; font-weight: bold;}
a:link.Navlink {color : Black;}
a:visited.Navlink {color : Black;}
a:active.Navlink {text-decoration: none;}
a:hover.Navlink {text-decoration: none;}
-->
</style>
<script language = "javascript">
<!--
function LmOver(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";
elem.style.cursor = 'hand'}
function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "Black";}
function LmDown(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";}
function LmUp(path)
{location.href = path;}
//-->
</script>
<table border="0" width="70" bgcolor="#000000" cellspacing="0" cellpadding="0">
<tr><td width="100%">
<table border="0" width="100%" cellspacing="1" cellpadding="1">
<tr><td width="100%" onMouseover="LmOver(this, 'Black')" onMouseout="LmOut(this, '#FFFFFF')" onMouseDown="LmDown(this, 'Black')"
onMouseUp="LmUp('troop230.html')" bgcolor="#FFFFFF"><A HREF="http://www.troop-230.org" Class="navlink"> HOME</a></td></tr>
</table>
</td></tr>
</table>
<a href="http://www.guistuff.com/"><img border="0" src="http://www.guistuff.com/images/11dot.gif" width="1" height="1"></a>
</center>
</body>
</html>

tommy
09-08-2004, 01:38 PM
Put the database connection in as an include at the top of your page, this will just help in the future if you ever change your database so you only have to change one connection string and not on every page.
e.g. <!--#include file="Include/connection.asp"-->

Try this connection for you database as I am not sure why you are naming two different sources
Set oConn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("\db\DatabaseName.mdb") & ";" & _
"Persist Security Info=False"
oConn.Open(sConnection)

Greg
09-09-2004, 11:35 AM
Good point about using an includes for connection I may have to look into doing that....
ok I now have my connection I believe working but I am getting this error now...

error '80004005'
/scoutlist.asp, line 26


set rsProds=Server.CreateObject("ADODB.Recordset")
(this is the line above 26

rsProds.Open strQuery, oConn, , , adCmdText
and this is line 26

any suggestion on this error?

tommy
09-09-2004, 01:13 PM
if you have the connection string that I showed you then you can have
(this has the oConn.Open)
set rsProds=oConn.execute(Name Of SQL Query)

or if you are using the one you specified above
(this has the dbConn.Open)

set rsProds=dbConn.execute(Name Of SQL Query)

replace both those lines (26 and the one above) with one of the lines above

Greg
09-09-2004, 08:45 PM
look at my code above in the first box ......


what is the name of my SQL Query :hmmmm: ?

I do not understand because I am using someone elses code and while I know some about
asp I do not know enought about this code...what do I need to put in the
(......)

Greg
09-10-2004, 05:19 AM
Thanks for helping me tommy when I tried below:

'set rsProds=Server.CreateObject("ADODB.Recordset")
'rsProds.Open strQuery, oConn, , , adCmdText
'define the options query

set rsProds=oConn.execute (strSQL)
I get the error message below

Microsoft JET Database Engine error '80040e0c'
Command text was not set for the command object.
/scoutlist.asp, line 2

if I try:
'set rsProds=Server.CreateObject("ADODB.Recordset")
'rsProds.Open strQuery, oConn, , , adCmdText
'define the options query

set rsProds=oConn.execute (strQuery)
same messages if I uncomment out
set rsProds=Server.CreateObject("ADODB.Recordset")


i get:
Microsoft JET Database Engine error '80040e0c'
Command text was not set for the command object.
/scoutlist.asp, line 29

tommy
09-11-2004, 09:47 AM
can you paste tour database connection or PM it to me and I will have a look becasue it doesnt seem to be connecting to it.

MikeParent
09-24-2004, 03:32 AM
Agreed Tommy. Greg, I would suspect your connect string is not working... I have not seen connect strings using UNC paths (\\servername) at an ISP before. This is pretty unusual I think and I would be surprised if the ISP has correctly set up cross-server permissions to allow this to happen... is there any chance of getting the ISP to look at this. Or can this database moved to the same box as the webserver? I would get the ISP support on-board with this.

Greg
09-24-2004, 06:07 AM
Mike,
you said:
"I have not seen connect strings using UNC paths (\\servername) at an ISP before"


yes this was odd for me too but I was instructed to start doing it this way when our troop
bump up to a paid service because i was able to use mappath connection string but can not now...let me show you a connection string that is working fine...look at following code :

<%

vip=Request.ServerVariables("REMOTE_ADDR")
vrefer=Request.ServerVariables("HTTP_REFERER") & Request.ServerVariables("URL")
vtime=time
vdate=date
vhost=Request.ServerVariables("REMOTE_HOST")
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;"_
& "Data Source=\\premfs15\sites\Premium15\troop230\database\track.mdb"

SQLString = "INSERT INTO t(ipnum, refer, currtime, currdate, remhost) VALUES('" & vip & "' , '" & vrefer & "' , #" & vtime & "# , #" & vdate & "# , '" & vhost & "')"
MyConn.Execute(SQLString)

MyConn.Close
Set MyConn = Nothing
%>
the above is good working code with a good connection string
this code is within this page:

http://troop230.brinkster.net/albright.asp

and then to see that the code is working you can look at the results of database on this page:

http://troop230.brinkster.net/gdatdispchk.asp


Thanks for checking in Mike but hey if you got simple code for a dropdown box
to return a query of the data let me know i came close to finding some code yesterday
but it was using two tables with three drop down really way more than I am doing
and that code is going to take a lot of modifing to work for me but I got the connection
string working and its like up above....

MikeParent
09-30-2004, 08:49 AM
Can you repost your code as it exists now?

Greg
09-30-2004, 11:05 AM
Mike,

here is the lastest error:
Pick a Scout
Microsoft JET Database Engine error '80040e0c'

Command text was not set for the command object.

/aaattgg.asp, line 32
and the page is here:
http://troop230.brinkster.net/aaattgg.asp

Tommy just sent me some new code and its not working but here is what he sent me
which is my lastest code and thanks Tommy!
<%@ language="VBScript" %>
<!-- #include file="adovbs.inc" -->
<html>
<head>
<title>Scout Lists</title>
<!-- ©2000 Abakada Web WorkShop; Author: Rey V. Nuñez -->
<link href="tutor.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
select {width:125}
-->
</style>
<%
vip=Request.ServerVariables("REMOTE_ADDR")
vrefer=Request.ServerVariables("HTTP_REFERER") & Request.ServerVariables("URL")
vtime=time
vdate=date
vhost=Request.ServerVariables("REMOTE_HOST")
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;"_
& "Data Source=\\premfs15\sites\Premium15\troop230\database\track.mdb"
%>

</head>

<body bgcolor ="#009999">
<div align="center">
<h3>Pick a Scout</h3>
<% rowCount=0
'create and open the products recordset
strQuery = "SELECT fname, rank, patrol, position, work FROM scout"
set rsProds=MyConn.Execute(strSQL)

'define the options query
strSQL="SELECT DISTINCT fname FROM scout"
'create and open the options recordset
set rsType=MyConn.Execute(strQuery)
%>
<form method="post">
Choose A Group <select name="fname">
<% do until rsType.EOF %>
<option><%= rsType("fname")%>
<% rsType.MoveNext
loop
'close options recset and flush from memory
rsType.Close
set rsType = Nothing %>
</select> <input type="submit" value="Show me">
</form>
<% if not isEmpty(Request("fname")) then
strType=Request("fname") %>
<h5>. . . retrieving <%= strType %> records for your question</h5>
<% 'filter the products query
rsProds.Filter = "fname = '" & strType & "'" %>
<table width=90% cellspacing=1 cellpadding=5 border=0>
<!-- begin column headers for Products table -->
<tr>
<th>Scout</th>
<th>Rank</th>
<th>Patrol</th>
<th>Position</th>
<th>Work</th></tr>
<% 'cycle thru the record set and display each row results
do until rsProds.EOF %>
<tr>
<td align="right"><%= rsProds("fname")%></td>
<td align="right"><%= rsProds("rank")%></td>
<td align="right"><%= rsProds("patrol")%></td>
<td align="right"><%= rsProds("position")%></td>
<td align="right"><%= rsProds("work")%></td></tr>
<!-- next Row = next Record -->
<% rowCount = rowCount+1
'increment record position with MoveNext method
rsProds.MoveNext
loop
'close connection and flush objects from memory
dbConn.Close
set dbConn = Nothing
set rsProds = Nothing %>
</table>
<% end if %>
</div>
<br>
<br>
<br>
</center>
<style type="text/css">
<!--
.Navlink {COLOR: #Black; TEXT-DECORATION: none; font-family: arial; font-size: 12pt; font-weight: bold;}
a:link.Navlink {color : Black;}
a:visited.Navlink {color : Black;}
a:active.Navlink {text-decoration: none;}
a:hover.Navlink {text-decoration: none;}
-->
</style>
<script language = "javascript">
<!--
function LmOver(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";
elem.style.cursor = 'hand'}
function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "Black";}
function LmDown(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";}
function LmUp(path)
{location.href = path;}
//-->
</script>
<table border="0" width="70" bgcolor="#000000" cellspacing="0" cellpadding="0">
<tr><td width="100%">
<table border="0" width="100%" cellspacing="1" cellpadding="1">
<tr><td width="100%" onMouseover="LmOver(this, 'Black')" onMouseout="LmOut(this, '#FFFFFF')" onMouseDown="LmDown(this, 'Black')"
onMouseUp="LmUp('troop230.html')" bgcolor="#FFFFFF"><A HREF="http://www.troop-230.org" Class="navlink"> HOME</a></td></tr>
</table>
</td></tr>
</table>
<a href="http://www.guistuff.com/"><img border="0" src="http://www.guistuff.com/images/11dot.gif" width="1" height="1"></a>
</center>
</body>
</html>

tommy
09-30-2004, 11:52 AM
sorry my fault I have noticed what I have done:

replace:
Line 32:
set rsProds=MyConn.Execute(strSQL) with set rsProds=MyConn.Execute(strQuery)
Line 37:
set rsType=MyConn.Execute(strQuery) with set rsType=MyConn.Execute(strSQL)

Greg
10-01-2004, 08:04 AM
oh tommy I hate to tell you this....but I made the change....heres the error:

Pick a Scout
error '80004005'
/aaattgg.asp, line 32

go up to my comments above to click the link to the page

tommy
10-01-2004, 10:07 AM
that error you are getting means to me that everything is working but you havent set your permissions on the database.

This will say who can Edit, Delete and Execute an SQL and who cant. You need to changes these to make the database work.

From looking on Brinkster you have to put the database in the 'db' folder as this has all the correct permissions for the database to work correctly. So you need to rename your database folder to db for it to work.

Greg
10-01-2004, 11:45 AM
I did looked that error up and while that is what we would expect the problem to be....
Yes Brinkster on their free service require all DB's to go into a folder called db but when we bump up to the paid service they wanted the DB's to go in a folder called database which is where I have the database....now I have a database in that folder in which I have asp pages Adding records, deleting
records and editing records.....

Before I contact Brinksters I have one more question...I notice in the information on this error
something about Access 97....could it be that this code needs to be using an XP database and
I have in there an Access 97 database if not or if you do not believe its a version problem then I will contact brinkster but I believe they are going to tell me I have full rights on that folder

tommy
10-02-2004, 10:48 AM
I dont beleive that it is the version as I have run Access 97 databases on brinkster many times and have had not trouble so I would contact brinkster just to confirm that they have set te access rights foryou database and database folder.

kako00000
07-31-2005, 07:31 AM
thanks u post I am new user

Terminator1138
08-05-2005, 06:45 AM
Did you notice it was an old post!!.....things like that happen over time...its the way of the web.