First You have to make SYSTEM DSN .For that follow this
Start -> settings -> control panel -> Administrator Tools -> Data Sources(ODBC) : then click on SYSTEM DSN and create your DSN.(For this U have to create your database in MS-access or SQL server 2000 as per ur choice.)
then use this code
' Dim connection As Long
' Dim destination(1 To 50 1 To 125) As Variant
' Dim retcode As long
' Dim query as String
' Dim outputStr as String
' connection SQLOpen( DSN master1 outputStr prompt: 1)
' query select * from data1 'Execute the query
' retcode SQLExecQuery(connection query)
' msgbox retcode
This last stmt shows you the retcode id connection successfully establised the a positive code will retured else negative code will be there.