Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Getting External Data

I have an interesting problem to solve and not really sure quite out to do
it. I have a back-end SQL Server Database that has several tables that I
need to pull data from into a single worksheet in Excel. Now, I am not a DBA
guru by any means. I have searched through the discussion group and all of
the VBA material that I own. Can someone point me in the right direction as
to being able to connect to one database and pull data from multiple tables?
The data is laid out where an employee's data is in one table (id, name,
address, city, state, zip) and another has their time charged (id, project #,
time charged) and yet another has their skills, specialties, and the roles
they do. I haven't written any code for this yet so I am just looking for
help with the concept.

Thanks a ton in advance,

Bryan47
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Getting External Data

This is not my strong area, but these statements worked for me. You will
have to replace items in "<" with whatever from your DBA. Note that
RS.GetRows returns a 2D array of cols by rows. You will need to transpose to
rows by cols.

Dim CM As ADODB.Command
Dim CN As ADODB.Connection
Dim RS As ADODB.Recordset

Set CN = New ADODB.Connection
CN.ConnectionString = "UID=<Login;PWD=<Password;driver={Microsoft ODBC for
Oracle};SERVER=<Instance;"
CN.CursorLocation = adUseClient
CN.Open

Set CM = New ADODB.Command
Set CM.ActiveConnection = CN

CM.CommandText = "SELECT * FROM <Domain.EmployeeTable"
CM.CommandType = adCmdText

Set RS = New ADODB.Recordset
RS.CursorType = adOpenStatic
RS.LockType = adLockReadOnly
Set RS.Source = CM

RS.Open
RS.MoveFirst
MyArray = RS.GetRows

RS.Close
Set RS = Nothing
Set CM = Nothing


"Type of Sheet displayed" wrote:

I have an interesting problem to solve and not really sure quite out to do
it. I have a back-end SQL Server Database that has several tables that I
need to pull data from into a single worksheet in Excel. Now, I am not a DBA
guru by any means. I have searched through the discussion group and all of
the VBA material that I own. Can someone point me in the right direction as
to being able to connect to one database and pull data from multiple tables?
The data is laid out where an employee's data is in one table (id, name,
address, city, state, zip) and another has their time charged (id, project #,
time charged) and yet another has their skills, specialties, and the roles
they do. I haven't written any code for this yet so I am just looking for
help with the concept.

Thanks a ton in advance,

Bryan47

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Getting External Data

hi
simpliest way may be to use MSQ. on the 2003 menu...
toolsGet external datanew database queryfollow the wizard.
you may have to get IT to help if passwords are an issue.
from experience, i would also suggest that you create a db in access, link
your server tables to the access db, write your queries in access then link
to the access querry via MSQ(microsoft query). it would seem like a round
about way to do it but access is more powerfull than MSQ, for versital. in
the past, i had trouble with a two table MSQ.s mostly with the joins. MSQ
wouldn't do left and right joins but access would do any kinds of join. and
linking to the access query via MSQ was easier that setting up a 2 table MSQ.
you could also look into ADO but unless you are a fair programmer, i would
stick to MSQ.

regards
FSt1

"Type of Sheet displayed" wrote:

I have an interesting problem to solve and not really sure quite out to do
it. I have a back-end SQL Server Database that has several tables that I
need to pull data from into a single worksheet in Excel. Now, I am not a DBA
guru by any means. I have searched through the discussion group and all of
the VBA material that I own. Can someone point me in the right direction as
to being able to connect to one database and pull data from multiple tables?
The data is laid out where an employee's data is in one table (id, name,
address, city, state, zip) and another has their time charged (id, project #,
time charged) and yet another has their skills, specialties, and the roles
they do. I haven't written any code for this yet so I am just looking for
help with the concept.

Thanks a ton in advance,

Bryan47

Reply
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
External Data Warning Message - I have No External Data in wrkbk Cass_makeitfun[_2_] Excel Discussion (Misc queries) 0 May 12th 10 09:02 PM
Getting External Data based on criteria insde of the external data BigMacExcel Excel Discussion (Misc queries) 0 August 31st 09 06:41 PM
Excel Macro for taking data external data and populating it on a sheet and deleting unwanted data [email protected] Excel Programming 3 November 8th 07 05:59 AM
insert entire row for new data, external data range doesnt work orlya1 Excel Programming 3 April 3rd 06 08:39 PM
Need advice : consolidating data from multiple CSV files in Excel - External data handling Matthieu Gaillet Excel Programming 0 December 1st 05 09:02 AM


All times are GMT +1. The time now is 11:36 AM.

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

About Us

"It's about Microsoft Excel"