Hi, I wonder if anyone can tell me the trick to query two different databases with two dropdowns.
I have two dropdowns. One is included as an include. At the top of the page I have one database connection: - <%@ Language=VBScript %>
-
<!--#Include File="miniart/dbconnect.asp"-->
-
<%
-
-
Dim oRs, conn, connect, strSQL
-
-
set conn=server.CreateObject ("adodb.connection")
-
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/mini.mdb") & ";Persist Security Info=False"
-
conn.Open connect
I need the second one to query a different database...anyone any ideas?
Thanks for any help.
Richard - <select onChange="window.location='http://www..com/mane.asp?CardDescription=' + this.options[this.selectedIndex].value">
-
<OPTION VALUE = art> art Option>
-
<OPTION>-----------------------------------------------------</Option>
-
<%
-
Set oRs=Server.CreateObject("adodb.recordset")
-
strSQL = "SELECT DISTINCT CardDescription FROM tblCards Where CategoryID <> " & 60 & " and CategoryID<>" & 61 & " ORDER BY Description"
-
'strSQL = "SELECT DISTINCT CardDescription FROM tblCards Where CategoryID<>" & 61 & " ORDER BY CardDescription"
-
-
oRs.Open strSQL, conn
-
-
Do while not oRs.EOF
-
if Request.Form("GreetingPostCards") = oRs("CardDescription") then 'if this is the selected one then display as selected
-
Response.Write "<OPTION VALUE = '" & oRS ("CardDescription") & "' SELECTED>"
-
Response.Write oRs("CardDescription") & "</Option>"
-
oRs.MoveNext
-
else
-
Response.Write "<OPTION VALUE = '" & oRs ("CardDescription") & "'> "
-
Response.Write oRs("CardDescription") & ",</Option>"
-
oRs.MoveNext
-
end if
-
loop
-
%>
-
</SELECT>
-
</div>
-
</form>
3 1636
Just thought I would say I worked this one out.
Putting this at the beginning of each drop down and directing them to the different databases did the trick - set conn=server.CreateObject ("adodb.connection")
-
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
-
Server.MapPath("/the two databases.mdb") & ";Persist Security Info=False"
-
conn.Open connect
Thanks
Richard
Hi, I wonder if anyone can tell me the trick to query two different databases with two dropdowns.
I have two dropdowns. One is included as an include. At the top of the page I have one database connection: - <%@ Language=VBScript %>
-
<!--#Include File="miniart/dbconnect.asp"-->
-
<%
-
-
Dim oRs, conn, connect, strSQL
-
-
set conn=server.CreateObject ("adodb.connection")
-
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/mini.mdb") & ";Persist Security Info=False"
-
conn.Open connect
I need the second one to query a different database...anyone any ideas?
Thanks for any help.
Richard - <select onChange="window.location='http://www..com/mane.asp?CardDescription=' + this.options[this.selectedIndex].value">
-
<OPTION VALUE = art> art Option>
-
<OPTION>-----------------------------------------------------</Option>
-
<%
-
Set oRs=Server.CreateObject("adodb.recordset")
-
strSQL = "SELECT DISTINCT CardDescription FROM tblCards Where CategoryID <> " & 60 & " and CategoryID<>" & 61 & " ORDER BY Description"
-
'strSQL = "SELECT DISTINCT CardDescription FROM tblCards Where CategoryID<>" & 61 & " ORDER BY CardDescription"
-
-
oRs.Open strSQL, conn
-
-
Do while not oRs.EOF
-
if Request.Form("GreetingPostCards") = oRs("CardDescription") then 'if this is the selected one then display as selected
-
Response.Write "<OPTION VALUE = '" & oRS ("CardDescription") & "' SELECTED>"
-
Response.Write oRs("CardDescription") & "</Option>"
-
oRs.MoveNext
-
else
-
Response.Write "<OPTION VALUE = '" & oRs ("CardDescription") & "'> "
-
Response.Write oRs("CardDescription") & ",</Option>"
-
oRs.MoveNext
-
end if
-
loop
-
%>
-
</SELECT>
-
</div>
-
</form>
It's not clear when you are wanting to query the other database. You can create a connection to a seperate database like this -
Dim oRs, conn, connect, strSQL, conn2, connect2
-
-
'first connection
-
set conn=server.CreateObject ("adodb.connection")
-
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/mini.mdb") & ";Persist Security Info=False"
-
conn.Open connect
-
-
'second connection
-
set conn2=server.CreateObject ("adodb.connection")
-
connect2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/otherdb.mdb") & ";Persist Security Info=False"
-
conn2.Open connect2
-
-
-
'query connection 2 using another recordset (if first recordset still open, otherwise just use oRS
-
Dim oRs2
-
Set oRs2=Server.CreateObject("adodb.recordset")
-
-
strSQL="blah blah blah"
-
oRs2.Open strSQL, conn2
-
-
Just thought I would say I worked this one out.
Putting this at the beginning of each drop down and directing them to the different databases did the trick - set conn=server.CreateObject ("adodb.connection")
-
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
-
Server.MapPath("/the two databases.mdb") & ";Persist Security Info=False"
-
conn.Open connect
Thanks
Richard
Yes you can (and should) do it that way if you know you don't need the first connection anymore sometimes you will.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: wimmie |
last post by:
Hello to all,
I have a 'small' problem. I have made a application in php that connect
trough ODBC to a Oracle RDB (VMS) or Basis+ database (VMS) and present the
data to a user. There are 2...
|
by: Mattyboy |
last post by:
Guys
I have built a database with saved queries that runs fine in Access
but when I call it from the web using ASP, an exception occurs. I
have tried multiple ways of testing the databases with...
|
by: noor.rahman |
last post by:
I was wondering how it may be possible to query 2 MySQL databases using
one query statement from PHP.
For instance: SELECT database1.tableA.field1 UNION
database2.tableB.field2.
My concern...
|
by: listerofsmeg01 |
last post by:
Hi,
Pretty new to PHP and MySQL.
I have a page on my site that displays a lot of information from
various tables. Currently I have lots of small PHP wrapper functions
around SQL queries to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |