I desire to import a table (SQL query) directly from SQL 2000 database to an excel spreadsheet. I must be missing something here. Does any have a simple code sample that would allow me to see what I'm missing. I do not seem to be able to get the connection working correctly.
<CODE FOLLOWS>
Dim dbs As Database
Dim qry As QueryDef
Dim rst As Recordset
dbs.Connect = "ODBC;DSN=LOCAL;UID=sa;PWD=target;DATABASE=contact"
Set qry = dbs.CreateQueryDef("myNAmes", "select * from dbo_C_tbl_Contacts")
Set rst = qry.OpenRecordset()
[A2].CopyFromRecordset rst
<END CODE>
I don't seem to be able to set the database in this example. Any help much welcomed. Thanks
<CODE FOLLOWS>
Dim dbs As Database
Dim qry As QueryDef
Dim rst As Recordset
dbs.Connect = "ODBC;DSN=LOCAL;UID=sa;PWD=target;DATABASE=contact"
Set qry = dbs.CreateQueryDef("myNAmes", "select * from dbo_C_tbl_Contacts")
Set rst = qry.OpenRecordset()
[A2].CopyFromRecordset rst
<END CODE>
I don't seem to be able to set the database in this example. Any help much welcomed. Thanks