LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Question on SQL from XL to Access

Using ADO, I was able to send a query to Access and get the result back. I
used the following code to extract the data from Access. My question is that
if I want to make multiple queries against the same db. Do I need to open and
close the db connection after every query? I tried keeping the connection
open and run against 2 queries to start with and I am getting an error on the
2nd query. It cannot proceed because I have to close the connection. What's
the most efficient way to pull data with mutliple SQL queries? I presume open
and close the connection everything would slow it down. True or False?

Thanks

Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")
Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
Cnct = Cnct & "Data Source=" & DBFullName & "; Jet OLEDB:Database
password=" & passwd & "; "
Connection.Open ConnectionString:=Cnct
Src = "SELECT fname, lname, address, city, state, zip from customer"
Recordset.Open Source:=Src, ActiveConnection:=Connection
Range("A1").CopyFromRecordset Recordset
Set Recordset = Nothing
Connection.Close
Set Connection = Nothing

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access question RollieG Excel Discussion (Misc queries) 6 October 27th 09 08:59 PM
Secondary Access Question Dan Charts and Charting in Excel 2 November 28th 06 12:49 AM
Access Form In An Access Report (SubForm) Question Gary Links and Linking in Excel 0 January 27th 06 05:54 AM
it's a question for access Mir Khan Excel Programming 1 December 15th 05 06:47 PM
Access Question SB1979 Excel Programming 1 October 15th 05 04:54 AM


All times are GMT +1. The time now is 07:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"