Question

asp multiple recordsets - store each in variable?

Asked by: WebGirlCrissy

I'm in the process of making a dynamic data map.  I've successfully pulled in data I need for one state however I need to do all 50 states, I know there's a cleaner way than doing 50+ recordsets, but cant seem to figure that out.  I'm running two queries per state (acquirers & sellers) -- I also need to put the query results in a variable to place within my JS popups instead of the static data. Here's the current code I have for one state (Oregon). And here's the link where you can see what's going on.  Again, the current popup data is 'static' the top of the page is showing the pulled data from the access db... code is below as well...hoping someone can steer me in the right direction here...Thanks!!http://www.morrisseygoodale.com/newsroom/mapmonthly/index.asp

<%  strSQL = "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Acquiror as Cat, AcquirorState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='OR')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;"
 
    Set objRS = Server.CreateObject ("ADODB.Recordset")
   	objRS.Open strSQL, ODBC_CNCT%>
	<% if objrs.eof = false then
	response.write "ACQUIRERS" %><br />
	<%Do While Not objRS.EOF %>
<%=objRS("cat")%><br />
<%objRS.movenext
Loop	
   objRS.Close
    Set objRS = Nothing 
	else
	response.write "ACQUIRERS(0)"
 end if%>
 <br />
 <%  strSQL = "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Seller as Cat, SellerState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='OR')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;"
 
    Set objRS = Server.CreateObject ("ADODB.Recordset")
   	objRS.Open strSQL, ODBC_CNCT%>
	<% if objrs.eof = false then
	response.write "SELLERS" %><br />
	<%Do While Not objRS.EOF
	dim count
	count = objRS("Expr1") 
	if count > 1 then %><%=objRS("cat")%> (<%=count%>) <%else%> <%=objRS("cat")%> <%  end if %>
<br />
<% 
objRS.movenext
Loop	
   objRS.Close
    Set objRS = Nothing 
	else
	response.write "SELLERS(0)"
 end if%>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-07-28 at 11:42:58ID24607248
Tags

asp

,

access db

Topics

Active Server Pages (ASP)

,

VB Database Programming

,

Access Coding/Macros

Participating Experts
1
Points
500
Comments
22

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. recordset from a recordset
    I want to run a query on a recordset. What I am trying to do is query an access dbase for certain records. Once I have that recordset I want to query those records to pull out more data. Can I does using ASP? How? dmfttm
  2. RecordSet in ASP
    Hello all, Iam looping through a recordset in ASP to create a table However when in a current record in the loop is there a way I can get a field value from the next record without moving to the next record in the recordset? Note: Iam not using the GetRows method. Iam loopi...
  3. Recordset
    Hi every Body I am trying to make a Program, I am using SQL Server as my Data Base and I am Using Microsoft Access in order to make my Forms and Reports. Here is the question: I want to use DAO Recordset in order to Enter some Data from a Form to a Table which is not related ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: saoirse1916Posted on 2009-07-28 at 12:29:48ID: 24964249

Rather than doing multiple recordsets and connections to the database I'd put all the SELECT statements into a single connection and jump through the recordsets using rs.NextRecordset().  Then save the data to arrays rather than keeping all those recordsets open.  Something like this:

'	Create as many arrDataX arrays as necessary (3 shown here for example)
Dim getDataConn, getDataCmd, rsData, strSQL, arrData1, arrData2, arrData3
 
'	Create your statement(s) -- only two shown here since this is what was posted, but just continue the string for more queries
strSQL = ( "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Acquiror as Cat, AcquirorState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='OR')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;" _
	& "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Seller as Cat, SellerState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='OR')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;" )
 
Set getDataConn = Server.CreateObject("ADODB.Connection")
getDataConn.Open ODBC_CNCT
Set getDataCmd = Server.CreateObject("ADODB.Command")
getDataCmd.ActiveConnection = getDataConn
getDataCmd.CommandText = strSQL
getDataCmd.CommandType = 1
 
'	Execute the query and save the first data to the first array
Set rsData = getDataCmd.Execute
If Not (rsData.BOF AND rsData.EOF) Then
	arrData1 = rsData.GetRows()
End If
 
'	Get the next recordset's data
Set rsData = getDataCmd.NextRecordset()
If Not (rsData.BOF AND rsData.EOF) Then
	arrData2 = rsData.GetRows()
End If
 
'	...and so on...
Set rsData = getDataCmd.NextRecordset()
If Not (rsData.BOF AND rsData.EOF) Then
	arrData3 = rsData.GetRows()
End If
 
'	Close the connections
rsData.Close()
Set rsData = Nothing
Set getDataCmd = Nothing
getDataConn.Close()
Set getDataConn = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:

Select allOpen in new window

 

by: WebGirlCrissyPosted on 2009-07-29 at 09:42:52ID: 24972007

hmm, i'm getting this error now....
_____________________
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Characters found after end of SQL statement.

/newsroom/mapmonthly/index.asp, line 66
________________________________
line 66 is:
Set rsData = getDataCmd.Execute

http://www.morrisseygoodale.com/newsroom/mapmonthly/index.asp

 

by: WebGirlCrissyPosted on 2009-07-29 at 11:01:33ID: 24972801

I've read that access doesnt support multiple recordsets with one sql statement...ugghh?   It would be crazy to create 50+ recordsets for each state's data and i'm guessing it would have issues loading the page.

 

by: saoirse1916Posted on 2009-07-29 at 14:14:49ID: 24974771

Ahh...well if that's the case then you might be stuck with multiple recordsets.  But, you can still dump each recordset into an array to take the load off off Access.

 

by: WebGirlCrissyPosted on 2009-07-29 at 14:42:45ID: 24975013

I'm unsure how I would turn my initial code above into an array and display my array results in my popups. Can you help me put this one state data into an array and advise how I would call these arrays within my map?  

 

by: saoirse1916Posted on 2009-07-30 at 07:16:21ID: 24980035

Sure, the code above will do it with a few modifications and I'm not exactly sure what you're trying to accomplish based on  your posted code but hopefully this will get you started.  If not, let me know.

'       Create variables
Dim getDataConn, getDataCmd, rsData, strSQL, arrData
 
'       Create your statement
strSQL = "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Acquiror as Cat, AcquirorState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='OR')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;"
 
'       Build the command
Set getDataConn = Server.CreateObject("ADODB.Connection")
getDataConn.Open ODBC_CNCT
Set getDataCmd = Server.CreateObject("ADODB.Command")
getDataCmd.ActiveConnection = getDataConn
getDataCmd.CommandText = strSQL
getDataCmd.CommandType = 1
 
'       Execute the query and save the data to the array
Set rsData = getDataCmd.Execute
If Not (rsData.BOF AND rsData.EOF) Then
        arrData = rsData.GetRows()
End If
 
'       Close the connections
rsData.Close()
Set rsData = Nothing
Set getDataCmd = Nothing
getDataConn.Close()
Set getDataConn = Nothing
 
'       Now it's time to use the data...
'	    Check for blank array
If IsArray(arrData) = True Then
	'	    Cycle through the array
	For i = 0 to uBound(arrData,2)
		Response.Write(arrData(0,x) & "<br>")
	Next
Else
	Response.Write("ACQUIRERS<br>")
End If

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:

Select allOpen in new window

 

by: WebGirlCrissyPosted on 2009-07-30 at 10:03:05ID: 24981932

ok, I now understand how to put the RS into the array, which I will work on. To give you a tad more info.. The sql statement used above is getting all ACQUIRERS from the database as well as grabbing the distinct count of the acquirers.  So the end result will look like this:
ACQUIRERS
abc company
def company
ghi company(3)  'meaning there's three ghi companies

and if there is no data the write:
ACQUIRERS(0)

Now I know once I retrieve the array i need to do some checking on the rs to get these results above. After the "if then" can turn the results into a variable?  So I can just call variables like <%=strOregonAcquirers> <%=strOregonSellers> within my javascript popups for each state on my map?

 

by: WebGirlCrissyPosted on 2009-07-30 at 11:21:05ID: 24982826

I need the rs array to do following and if there isnt any data in the array to display "ACQUIRERS(0)". I'm unable to figure out how i can incorporate the 'Do While' into this array and how i can save this info so I can just place the variable in my popup.  I'm hoping that makes some sense ....

<% if objrs.eof = false then
      response.write "ACQUIRERS" %><br />
      <%Do While Not objRS.EOF
      dim count
      count = objRS("Expr1")
      if count > 1 then %><%=objRS("cat")%> (<%=count%>) <%else%> <%=objRS("cat")%> <%  end if %>
The above code does exactly what a want but of course need the array equivalent: ie,
ACQUIRERS
abc company
def company
ghi company(3)

And then somehow save this data so I can place it in my map popups.

 

by: WebGirlCrissyPosted on 2009-07-30 at 14:05:39ID: 24984395

ok, i've got one array working thank you for all your input thus far!! I just need to figure out how to place the output within my map popups. Here's my working array code below:

<%  strSQL = "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Seller as Cat, SellerState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='OR')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;"

    Set objRS = Server.CreateObject ("ADODB.Recordset")
         objRS.Open strSQL, ODBC_CNCT
      
      MyArray = objrs.GetRows()
      Const AcquirorStateCatOrdinal = 0
      Const AcquirorStateOrdinal = 1
      Const AcquirorNumOrdinal = 2
      
Ubound MyArray,1 'Returns the Number of Columns
Ubound MyArray,2 'Returns the Number of Rows
 
If IsArray(MyArray) = True Then
Response.write "SELLERS"  & "<BR>" & vbNewLine
For lnLoopCounter = 0 To Ubound(MyArray,2)
Response.Write MyArray(AcquirorStateCatOrdinal, lnLoopCounter) & "(" & MyArray(AcquirorNumOrdinal, lnLoopCounter) & ")" & "<BR>" & vbNewLine
Next
Else
      Response.Write "SELLERS(0)"
End If%>


Which outputs this:

SELLERS
DuPont Engineering(2)
Gaylord Land Surveying (1)
Geo-Spatial Solutions Inc.(1)
WRG Design(1)

Now i need to get the above output into the onmouseover event (see below):

<area shape="rect" coords="106,101,141,133" href="#" onmouseover="Tip('<b>Oregon</b> OUTPUT RIGHT HERE, baloon, true, ABOVE, false, OFFSETY, 22)" onmouseout="UnTip()" />

THANKS!!

 

by: saoirse1916Posted on 2009-07-30 at 14:53:00ID: 24984755

Sorry for the delay in getting back to you, lots of meetings today... anyway, if you need to get your output into that HTML, here's what you'd do.  Now, I have no idea where you're getting the coordinates -- your query doesn't seem to grab them which means they're not in your recordset/array, if I'm reading things correctly -- so these will all display on top of each other.  You'll need some way to dynamically collect the coordinates, probably by way of some additional database fields.

<%
For i = 0 to uBound(MyArray,2)
	Response.Write("<area shape=" & chr(34) & "rect" & chr(34) & " coords=" & chr(34) & "106,101,141,133" & chr(34) & " href=" & chr(34) & "#" & chr(34) & " onmouseover=" & chr(34) & "Tip('<b>Oregon</b> " & MyArray(0,i) & "<br>" & MyArray(1,i) & "<br>") & MyArray(2,i) & "<br>") & MyArray(3,i) & "<br>" & MyArray(4,i) & "<br>" & ", baloon, true, ABOVE, false, OFFSETY, 22)" & chr(34) & " onmouseout=" & chr(34) & "UnTip()" & chr(34) & " />"
Next
%>

                                              
1:
2:
3:
4:
5:

Select allOpen in new window

 

by: saoirse1916Posted on 2009-07-30 at 15:02:20ID: 24984802

Oops, sorry -- I completely misunderstood your data.  Try this instead:

<%
Dim varPopupText
For i = 0 to uBound(MyArray,2)
	varPopupText = varPopupText & MyArray(0,i) & "(" & MyArray(2,i) & ")" & "<br>"
Next
Response.Write("<area shape=" & chr(34) & "rect" & chr(34) & " coords=" & chr(34) & "106,101,141,133" & chr(34) & " href=" & chr(34) & "#" & chr(34) & " onmouseover=" & chr(34) & "Tip('<b>Oregon</b> " & varPopupText & ", baloon, true, ABOVE, false, OFFSETY, 22)" & chr(34) & " onmouseout=" & chr(34) & "UnTip()" & chr(34) & " />"
%>	
                                              
1:
2:
3:
4:
5:
6:
7:

Select allOpen in new window

 

by: WebGirlCrissyPosted on 2009-07-30 at 16:28:35ID: 24985272

awesome - works like a charm!!!
Now I will just need to do this for each of my states...Any suggestions on a clean approach for me to create a bunch?

 

by: saoirse1916Posted on 2009-07-31 at 07:14:02ID: 24988947

Well, you can load all the states into an array and loop through them the same way as you did before -- basically it would become a nested loop, so you have to be careful about referencing the correct counter.  Something like this:

'	Create array of states, remember 0 based index so total would be 49
Dim arrStates(49), varPopupText
arrStates(0) = "Alabama"
arrStates(1) = "Alaska"
arrStates(2) = "Arizona"
'	etc....
arrStates(49) = "Wyoming"
 
'	Now cycle through the array
For x = 0 to uBound(arrStates,1)
	'	Now write the code we came up with before -- notice I've replaced "Oregon" with the active item from the states array
	For i = 0 to uBound(MyArray,2)
        varPopupText = varPopupText & MyArray(0,i) & "(" & MyArray(2,i) & ")" & "<br>"
	Next
	Response.Write("<area shape=" & chr(34) & "rect" & chr(34) & " coords=" & chr(34) & "106,101,141,133" & chr(34) & " href=" & chr(34) & "#" & chr(34) & " onmouseover=" & chr(34) & "Tip('<b>" & arrStates(x) & "</b> " & varPopupText & ", baloon, true, ABOVE, false, OFFSETY, 22)" & chr(34) & " onmouseout=" & chr(34) & "UnTip()" & chr(34) & " />"
Next

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: saoirse1916Posted on 2009-07-31 at 07:16:19ID: 24988968

Oops...proofreading before posting would take all the fun out of it.  One change:

'	Create array of states, remember 0 based index so total would be 49
Dim arrStates(49), varPopupText
arrStates(0) = "Alabama"
arrStates(1) = "Alaska"
arrStates(2) = "Arizona"
'	etc....
arrStates(49) = "Wyoming"
 
'	Now cycle through the array
For x = 0 to uBound(arrStates,1)
	'	Clear the varPopupText variable with each state
	varPopupText = ""
	'	Now write the code we came up with before -- notice I've replaced "Oregon" with the active item from the states array
	For i = 0 to uBound(MyArray,2)
        varPopupText = varPopupText & MyArray(0,i) & "(" & MyArray(2,i) & ")" & "<br>"
	Next
	Response.Write("<area shape=" & chr(34) & "rect" & chr(34) & " coords=" & chr(34) & "106,101,141,133" & chr(34) & " href=" & chr(34) & "#" & chr(34) & " onmouseover=" & chr(34) & "Tip('<b>" & arrStates(x) & "</b> " & varPopupText & ", baloon, true, ABOVE, false, OFFSETY, 22)" & chr(34) & " onmouseout=" & chr(34) & "UnTip()" & chr(34) & " />"
Next

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:

Select allOpen in new window

 

by: WebGirlCrissyPosted on 2009-07-31 at 07:26:24ID: 24989056

great Awesome -- and what about the multiple recordsets SQL's, cleaner approach to that as well?

 

by: WebGirlCrissyPosted on 2009-07-31 at 07:27:45ID: 24989067

Should I open/close connection for each RS needed?

 

by: saoirse1916Posted on 2009-07-31 at 07:53:48ID: 24989311

If Access doesn't support multiple queries per connection then I think you'll have to.  If I understand correctly, you're going to need one query per state so you can use your states array to loop that.  I see you're using the abbreviation in your query so you'd have to make a change to your states array to hold both the abbreviation (for the query) and the full name (for display to the user).  So, putting it all together would look something like this:

'	Create variables
Dim getDataConn, getDataCmd, rsData, strSQL, arrData, arrStates(1,49), varPopupText
 
'	Create array of states, now using a 2-dimensional array to hold name + abbreviation
arrStates(0,0) = "Alabama"
arrStates(1,0) = "AL"
arrStates(0,1) = "Alaska"
arrStates(1,1) = "AK"
arrStates(0,2) = "Arizona"
arrStates(1,2) = "AR"
'	etc....
arrStates(0,49) = "Wyoming"
arrStates(1,49) = "WY"
 
'	Now cycle through the array
For x = 0 to uBound(arrStates,1)
 
	'	Create your statement specific to the active state in the loop
	strSQL = "SELECT [%$##@_Alias].Cat, [%$##@_Alias].State, Count(*) AS Expr1 FROM [select Acquiror as Cat, AcquirorState as State FROM 2007Data]. AS [%$##@_Alias] WHERE ((([%$##@_Alias].State)='" & arrState(1,x) & "')) GROUP BY [%$##@_Alias].Cat, [%$##@_Alias].State;"
	 
	'	Build the command
	Set getDataConn = Server.CreateObject("ADODB.Connection")
	getDataConn.Open ODBC_CNCT
	Set getDataCmd = Server.CreateObject("ADODB.Command")
	getDataCmd.ActiveConnection = getDataConn
	getDataCmd.CommandText = strSQL
	getDataCmd.CommandType = 1
	 
	'	Execute the query and save the data to the array
	Set rsData = getDataCmd.Execute
	If Not (rsData.BOF AND rsData.EOF) Then
		arrData = rsData.GetRows()
	End If
	 
	'	Close the connections
	rsData.Close()
	Set rsData = Nothing
	Set getDataCmd = Nothing
	getDataConn.Close()
	Set getDataConn = Nothing
 
	'	Now we write the data
	varPopupText = ""
	For i = 0 to uBound(arrData,2)
		varPopupText = varPopupText & arrData(0,i) & "(" & arrData(2,i) & ")" & "<br>"
	Next
	Response.Write("<area shape=" & chr(34) & "rect" & chr(34) & " coords=" & chr(34) & "106,101,141,133" & chr(34) & " href=" & chr(34) & "#" & chr(34) & " onmouseover=" & chr(34) & "Tip('<b>" & arrStates(0,x) & "</b> " & varPopupText & ", baloon, true, ABOVE, false, OFFSETY, 22)" & chr(34) & " onmouseout=" & chr(34) & "UnTip()" & chr(34) & " />"
Next

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:

Select allOpen in new window

 

by: saoirse1916Posted on 2009-07-31 at 07:57:17ID: 24989344

Another thought -- I seem to have the best ones *after* I've posted -- you'll probably want to take into account the possibility of having no data for a particular state.  So I'd take this:

'       Now we write the data
varPopupText = ""
For i = 0 to uBound(arrData,2)
        varPopupText = varPopupText & arrData(0,i) & "(" & arrData(2,i) & ")" & "<br>"
Next

And turn it into this:

'       Now we write the data
varPopupText = ""
If IsArray(arrData) = True Then
        For i = 0 to uBound(arrData,2)
                varPopupText = varPopupText & arrData(0,i) & "(" & arrData(2,i) & ")" & "<br>"
        Next
Else
        varPopupText = "No Data Found for this State"
End If

 

by: WebGirlCrissyPosted on 2009-07-31 at 10:49:52ID: 24990944

I actually have 2 queries per state, one SELECT SELLERS the other SELECT ACQUIRERS per state. I will be working on your latest input tonight... Thank you so much!!!!!
:))

 

by: saoirse1916Posted on 2009-07-31 at 12:39:04ID: 24991785

Ahh -- well, you can either run both queries in the state loop or you should be able to combine them into one SQL command...I'm not much of an Access person though, so I'm not quite sure on the syntax.



 

by: WebGirlCrissyPosted on 2009-08-05 at 20:46:50ID: 31608899

Thank you again for all your help and patience!  Its working wonderfully for me now
:) Crissy

 

by: WebGirlCrissyPosted on 2009-09-02 at 06:19:49ID: 25240701

Hey there - I'm stuck again and have opened up a new ticket but since you have some familiarity with my question in the past i'm hoping you could steer me in the right direction.  I would like to open up this question again for you and award you 500 points. I need to adjust the array that i've set up for all my 50 states.  My query now needs to pull just he company name and new field "LINK" which i need to have the companyname link ie;  <a href="http:company1LInk">company1</a> displayed in my js popups via a variable. My code below is just pulling the Acquiror(companyname) right now. I've tried to link up the array but getting errors...  Ideally i need the variable to hold <a href="http:company1LInk">company1</a>

<%  'AL ACQUIROR
strSQL = "SELECT [2009Data].Acquiror, [2009Data].LINK FROM 2009Data WHERE ((([2009Data].AcquirorState)='AL'));"
 
    Set objRS = Server.CreateObject ("ADODB.Recordset")
         objRS.Open strSQL, ODBC_CNCT
            If Not objRS.EOF Then
      MyArray = objrs.GetRows()
      
Ubound MyArray,1 'Returns the Number of Columns
Ubound MyArray,2 'Returns the Number of Rows
 
Dim varALPopupTextA
For i = 0 to uBound(MyArray,2)
            
      varALPopupTextA = varALPopupTextA & "- " &  MyArray(0,i)
            
Next
Else
      varALPopupTextA = "- (0)<BR>"
End If
objrs.Close()
      Set objrs = Nothing

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...