' Guided into the name space
Imports ADODB
Imports Microsoft.Office.Interop
Private Sub A1 ()
Dim SQL as String
Dim Cnn as New ADODB. Connection
Dim Rs as New ADODB. Recordset
Dim S as String
S = "PROVIDER=ORAOLEDB.ORACLE.1; password= password; Persist Security info=true; User id= username; Data source= Connect Location "
Cnn.open (S)
Rs.cursorlocation = ADODB. Cursorlocationenum.aduseclient
SQL = "Select Img_file. IMG01 from SH01. Img_file "
Rs.Open (SQL, Cnn, 3, 3)
Dim Xls as Excel.Application = New excel.application ' Define EXCEL application
Dim Xlsbook as Excel.Workbook ' Define workbook
Dim xlssheet as Excel.Worksheet ' definition sheet
Xlsbook = Xls.Application.Workbooks.Add ' Add a new workbook
Xlssheet = xlsbook.sheets (1) ' Control handle to worksheet 1th
xls.visible = True ' Show Excel program
Xlssheet.cells (1, 1). Value = "Table 1"
Xlssheet.range ("A2"). CopyFromRecordset (Rs)
Xlssheet.Cells.EntireColumn.AutoFit ()
Xls = Nothing ' releases Excel object
Rs.cancel ()
End Sub
VB.net using ADODB to connect to Excel