I want to export data from db2 tables to csv format.I also need that first row should be all the column names.
QRYSTR = "SELECT * FROM WCPGDBA.TPAYGO_PARTNER"
Set DBCON = CreateObject("ADODB.Connection")
DBCON.ConnectionString = DBCONSRT
DBCON.Open
'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
Sheets("Sheet1").Range("B2").Offset(1, 0).CopyFromRecordset DBRS
End With
End Sub
SHeet1 has the data but column names are missing
QRYSTR = "SELECT * FROM WCPGDBA.TPAYGO_PARTNER"
Set DBCON = CreateObject("ADODB.Connection")
DBCON.ConnectionString = DBCONSRT
DBCON.Open
'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
Sheets("Sheet1").Range("B2").Offset(1, 0).CopyFromRecordset DBRS
End With
End Sub
SHeet1 has the data but column names are missing