SQLScholar
Programmer
Hey all,
I have a piece of VB.net code within SSIS that seems to do nearly what i want it to do. However where i am currently saying
it brings back what is on row 2. I want the row headers first, so i want whats on row1. Or the column name, field name - however you want to call it. How can i get this? Here is my current code:
TIA
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I have a piece of VB.net code within SSIS that seems to do nearly what i want it to do. However where i am currently saying
Code:
MsgBox(Reader.Item(0))
it brings back what is on row 2. I want the row headers first, so i want whats on row1. Or the column name, field name - however you want to call it. How can i get this? Here is my current code:
Code:
Dim excelFile As String
Dim connectionString As String
Dim conn As OleDbConnection
Dim Reader As OleDbDataReader
Dim cmd As New OleDbCommand
Dim SheetArray As String() = DirectCast(Dts.Variables("Sheetnames").Value, System.String())
connectionString = "Provider =Microsoft.Jet.OLEDB.4.0; Data Source =""" + Dts.Variables("Filename").Value.ToString + """; Extended Properties =""Excel 8.0;HDR=Yes;IMEX=1""; "
conn = New OleDbConnection(connectionString)
conn.Open()
cmd.Connection = conn
For Each Sheet As String In SheetArray
cmd.CommandText = "SELECT * from [" + Sheet + "]"
Reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Try
While (Reader.Read)
MsgBox(Reader.Item(0))
End While
Finally
Reader.Close()
End Try
Next
conn.Close()
conn = Nothing
TIA
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------