Thank you very much.. this is really helpful... I have couple of other questions
With the below code I am establishing my connection to db.. Correct ?? Then should I just put in the remote machine details If I am connecting to someother db on a remote server
Code:
Set excel_app = CreateObject("Excel.Application")
DBCONSRT = "Driver={IBM DB2 ODBC DRIVER};Database=<DATABASE NAME>;hostname=<HOSTMACHINENAME>;port=<PORT_NUMBER;protocol=TCPIP; uid=<USER_ID>; pwd=<PASSWORD>"
'CHANGE THE BELOW QUERY STRING ACCORDIGN TO YOUR NEED
QRYSTR = "select B.TBNAME as tabname,count(B.NAME)as colcount from SYSIBM.SYSTABLES A,SYSIBM.SYSCOLUMNS B WHERE A.NAME=B.TBNAME AND A.CREATOR=B.TBCREATOR AND A.TYPE='T' AND B.TBCREATOR='<OWNER_NAME>' group by B.TBNAME"
Set DBCON = CreateObject("ADODB.Connection")
DBCON.ConnectionString = DBCONSRT
DBCON.Open
Code:
'BELOW CODE USED TO GET THE DATABASE CONECTION AND EXECUTE THE QUERY CHANGE ACCORDIGN TO YOUR NEED
Set DBRS = CreateObject("ADODB.Recordset")
With DBRS
.Source = QRYSTR
Set .ActiveConnection = DBCON
.Open
End With
End Sub
Can you help me with this part ?? Can you explain how the query is executed and how do I write the data to the excel cells ??
Finally, Guys Is there a book or something.. where I can read all these... I am sure these are covered in somebooks but I am not aware of which one.. please help me out...