473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Database into an array

I have a database of Company titles that I want to grab from an access
database, put into an asp array and then pass it to javascript so I can
output it into a CSS styled javascript menu. Right now I am stuck on
how to exactly put the database entries into an asp array. Below is
what I have so far. So I want it to return distinct entries from the
Title field and put it into the array called Titles after the asp code
has done an HTMLEncode to make sure I can also pass it along to another
asp page. Basically I need to know what to put after the Do While NOT
Rs.EOF. Any help would be appreciated.
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open "PhoneList"
sSQL = "SELECT DISTINCT Title FROM Everyone WHERE Location='Admin' AND
Not Title IS NULL ORDER BY Title ASC"
Set Rs = Conn.Execute(sSQL)
Do While NOT Rs.EOF

Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
%>

Dec 15 '05 #1
2 5966
MasterChief wrote:
I have a database of Company titles that I want to grab from an access
database, put into an asp array and then pass it to javascript so I can
output it into a CSS styled javascript menu. Right now I am stuck on
how to exactly put the database entries into an asp array. Below is
what I have so far. So I want it to return distinct entries from the
Title field and put it into the array called Titles after the asp code
has done an HTMLEncode to make sure I can also pass it along to another
asp page. Basically I need to know what to put after the Do While NOT
Rs.EOF. Any help would be appreciated.
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open "PhoneList"
sSQL = "SELECT DISTINCT Title FROM Everyone WHERE Location='Admin' AND
Not Title IS NULL ORDER BY Title ASC"
Set Rs = Conn.Execute(sSQL)
Do While NOT Rs.EOF

Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
%>

Instead of setting your record set into a local variable, just set it in
a session variable. Then all your pages can access the same record set.
Dec 16 '05 #2
MasterChief wrote:
I have a database of Company titles that I want to grab from an access
database, put into an asp array and then pass it to javascript
You mean client-side code?
so I
can output it into a CSS styled javascript menu. Right now I am stuck
on how to exactly put the database entries into an asp array.
GetRows
Below is
what I have so far. So I want it to return distinct entries from the
Title field and put it into the array called Titles after the asp code
has done an HTMLEncode to make sure I can also pass it along to
another asp page. Basically I need to know what to put after the Do
While NOT Rs.EOF. Any help would be appreciated.
<% dim arData Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open "PhoneList"
sSQL = "SELECT DISTINCT Title FROM Everyone WHERE Location='Admin'
AND Not Title IS NULL ORDER BY Title ASC"
Set Rs = Conn.Execute(sSQL)

If NOT Rs.EOF then

arData=Rs.GetRows
end if

Then store the array in Session.
You will not be able to pass the array as-is to client-side script. You will
need to extract the data you want from the array, creating a delimited
string which can be passed to the client-side code which can use the Join
method to create an array from te string. I've posted examples of this in
this group in the past, so use Google to find them.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: James | last post by:
Hi, Have posted before, but will simplify problem here. For original post go to http://forums.devshed.com/t80025/s.html I have setup 2 arrays like so in my one page script: $carers =...
2
by: lawrence | last post by:
I had some code that worked fine for several weeks, and then yesterday it stopped working. I'm not sure what I did. Nor can I make out why it isn't working. I'm running a query that should return 3...
5
by: lawrence | last post by:
I posted before, but have now narrowed my problem down to this method. At the start of the method, I test to make sure that I have a resource, a pointer to data returned from a database. This test...
4
by: George Stout | last post by:
First off I do not know alot about writing queries to an Access Database from an ASP page. This is why I need help. I have an Events database for 6 colleges in our metro area. On the homepage I...
0
by: EMiller | last post by:
Hello, I am encountering a development challenge here that seems to be stumping me. I am developing a C#/.NET application using an MSDE database. There is a particular field in a table that I...
1
by: garimapuri | last post by:
hi ihad an array in php and iwant to insert its value in database the coding is: <?php $nv_pairs = explode('&',$query_string); $array; list ($name, $value) = explode ('=',$nv_pairs); $i = 0;...
4
by: Haydnw | last post by:
Hi, I'd like to put a load of database results (several rows for 5 fields) into a two-dimensional array. Now, this may be a really stupid question, but can someone give me a pointer for how to...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
2
by: conspiracy cam | last post by:
Hi. Trying to create a program which splits up a large amount of text into small pieces, puts these pieces into a database, allowing for later reuse. The problem is since each text file is a...
0
by: windandwaves | last post by:
Hi Folk What do you think about this database class? Do you have any feedback or ideas on how it could be improved? Thank you Nicolaas class dbClass {
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.