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
|