Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SSIS: Loading EXCEL into SQL Server - Cells w/ Data Load a..

 
   Database Forums (Home) -> Data Warehouse RSS
Next:  How to pass 'GETDATE()' as SqlParameter  
Author Message
ITContractor

External


Since: May 01, 2006
Posts: 6



(Msg. 1) Posted: Sun Dec 30, 2007 5:08 pm
Post subject: SSIS: Loading EXCEL into SQL Server - Cells w/ Data Load as NULL !
Archived from groups: microsoft>public>sqlserver>datawarehouse (more info?)

Greetings,

I've been trying to load the EXCEL Spreadsheet:
http://tonto.eia.doe.gov/dnav/pet/pet_pri_gnd_dcus_nus_w.htm
HTTP downloaded using the "Download Series History" link.
into SQL Server 2005 using SSIS.

In two cases:

1. Using an "EXCEL Connection Manager" and an "EXCEL Source" object
AND
2. "Script Task" code:
Dim cnn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=F:\DOE-EIA\SSIS Production Sub-Directories\SSIS
Import\PET_PRI_GND_DCUS_NUS_W.xls;Extended Properties=""Excel 8.0;HDR=YES;""")
Dim da As New OleDb.OleDbDataAdapter("Select * from [1-Weekly Retail
Gasoline and Di$]", cnn)
Dim ds As New DataSet("ExcelFile")
Dim column As Int32
Dim row As Int32
Dim cellData As String

da.Fill(ds)

For row = 221 To 222 'ds.Tables.Item(0).Rows.Count
For column = 0 To 4 '(ds.Tables.Item(0).Columns.Count - 1)
If ds.Tables.Item(0).Rows(row).Item(column) Is DBNull.Value
Then
cellData = "NULL"
Else
cellData =
CType(ds.Tables.Item(0).Rows(row).Item(column), String)
End If
MsgBox(cellData, MsgBoxStyle.Information, "ExcelData")
Next column
Next row

>>> The second, third and fourth colunms (among others) of the Speradsheet
return NULL values although the Spreadsheet obviously contains data
in
those cells.

Any ideas are appreciated.

 >> Stay informed about: SSIS: Loading EXCEL into SQL Server - Cells w/ Data Load a.. 
Back to top
Login to vote
ITContractor

External


Since: May 01, 2006
Posts: 6



(Msg. 2) Posted: Thu Jan 10, 2008 9:49 am
Post subject: RE: SSIS: Loading EXCEL into SQL Server - Cells w/ Data Load as NULL ! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Sam Wilson" wrote:

> Or just add IMEX=1 after HDR=Yes in your code...
>
> I should read things before I reply.
>
> "Sam Wilson" wrote:
>
> > Are the columns that aren't importing properly a mixture of numbers and
> > strings?
> >
> > If you have numbers in a column, even if they're in excel as strings, then
> > the non-numeric values are skipped by SSIS, it took me ages to find that.
> >
> > In the design studio, right-click on the connection in connection managers -
> > go to propertioes and change the connection string to include "IMEX=1"


"ITContractor" wrote:

> Greetings,
>
> I've been trying to load the EXCEL Spreadsheet:
> http://tonto.eia.doe.gov/dnav/pet/pet_pri_gnd_dcus_nus_w.htm
> HTTP downloaded using the "Download Series History" link.
> into SQL Server 2005 using SSIS.
>
> In two cases:
>
> 1. Using an "EXCEL Connection Manager" and an "EXCEL Source" object
> AND
> 2. "Script Task" code:
> Dim cnn As New
> OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=F:\DOE-EIA\SSIS Production Sub-Directories\SSIS
> Import\PET_PRI_GND_DCUS_NUS_W.xls;Extended Properties=""Excel 8.0;HDR=YES;""")
> Dim da As New OleDb.OleDbDataAdapter("Select * from [1-Weekly Retail
> Gasoline and Di$]", cnn)
> Dim ds As New DataSet("ExcelFile")
> Dim column As Int32
> Dim row As Int32
> Dim cellData As String
>
> da.Fill(ds)
>
> For row = 221 To 222 'ds.Tables.Item(0).Rows.Count
> For column = 0 To 4 '(ds.Tables.Item(0).Columns.Count - 1)
> If ds.Tables.Item(0).Rows(row).Item(column) Is DBNull.Value
> Then
> cellData = "NULL"
> Else
> cellData =
> CType(ds.Tables.Item(0).Rows(row).Item(column), String)
> End If
> MsgBox(cellData, MsgBoxStyle.Information, "ExcelData")
> Next column
> Next row
>
> >>> The second, third and fourth colunms (among others) of the Speradsheet
> return NULL values although the Spreadsheet obviously contains data
> in
> those cells.
>
> Any ideas are appreciated.
>
>

 >> Stay informed about: SSIS: Loading EXCEL into SQL Server - Cells w/ Data Load a.. 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> Data Warehouse All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]