07-25-2008, 03:09 AM
Hi Siri ,
Modified Code...
Please use the above code and i tried this on my computer it is working so please let me know any problem.
Modified Code...
Code:
Set Conn = CreateObject("ADODB.Connection")
Set Rs = CreateObject("ADODB.recordset")
Conn.Open("DRIVER={Oracle in OraHome92};SERVER=DEVMITG;
UID=ITL_ASSET;PWD=ITL_ASSET;DBQ=DEVMITG")
' Specify the query'
sql = "Select Code, Meaning From TB_AMS052_Codes Where Code_Nam = Pole"
'Set the recordset cursor type’
Rs.CursorType = 1
'Execute the Query’
Rs.Open sql,Conn
'Get the no records returned by query’
Recordcount = Rs.RecordCount
'Adding a column to datatable’
DataTable.GlobalSheet.AddParameter "Meaning",""
DataTable.GlobalSheet.AddParameter "Code",""
'Get the values from the Meaning column’
While(NOT Rs.EOF)
'Msgbox Rs.Fields("Meaning")
For i=1 to Recordcount
DataTable.SetCurrentRow(i)
'Writing the data to the datatable’
DataTable("Meaning",DtGlobalSheet) = Rs.Fields("Meaning")
DataTable("Code",DtGlobalSheet) = Rs.Fields("Code")
Rs.MoveNext
Next
wend
'close the database connection’
DataTable.Export "C:\DatabaseExample.xls"
Conn.close
Set Conn = Nothing
Set Rs = Nothing
Please use the above code and i tried this on my computer it is working so please let me know any problem.