Gi Don,
With ADO it is straight-forward thing. Here is some sample code
Sub GetData()
Dim oConn As ADODB.Connection
Dim oRS As ADODB.Recordset
dim sSQL as string
Dim myArray
Set oConn = New ADODB.Connection
oConn.CursorLocation = adUseClient
oConn.Open "Provider=sqloledb;" & _
"Data Source=myServerName;" & _
"Initial Catalog=myDatabaseName;" & _
"User Id=myUsername;" & _
"Password=myPassword"
Set oRS = New Recordset
sSQL = "select * from [MyTable]",
oRS.Open sSQL,oConn, adOpenStatic, adLockOptimistic
'load a worksheet
Range("A2").CopyFromRecordset oRS
'load an array
my = oRS.GetRows()
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
End Sub
You should set a reference to the ACtiveX Data Objects and ACtuiveX Data
Objects Recordset libraries in ToolsReferences.
Also change the values in tyhe connection string to suit
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Don Grover" wrote in message
...
Hi All
I need to retrieve data from MSSQL2k Server table and populate the
spreadsheet page with the table data.
I can do this with a DSN and run querry data but I need to build the
connection string into the spreadsheet itself so when a tab is clicked it
retrieves a qry for that page.
I understand sql & connection details a bit so can work through a sample
to
use in my situation.
The reason I want to email pass data to an employee from a remote site but
do not want to make the connection details available to anyone.
Also I just want to email the spreadsheet to employee so they don not have
to install dsn or configure any connection details.
Is this possible, and is it a tall order as if it is im will to renumerate
for any help.
Regards
Don