dbasplus
asked on
Import Excel sheet into SQL table
I'm trying to create a simple VB.Net program that imports an Excel sheet into a SQL server database table.
As the format of the excel file is fixed and can not be altered it can not be a straight import.
The import needs to start at line 13 and I need to import selected columns into the correct column in SQL server.
Im hoping to do this in code and not through SSIS, but will bow down if this really is the best and quickest way.
Any idea or examples please?
As the format of the excel file is fixed and can not be altered it can not be a straight import.
The import needs to start at line 13 and I need to import selected columns into the correct column in SQL server.
Im hoping to do this in code and not through SSIS, but will bow down if this really is the best and quickest way.
Any idea or examples please?
Import the data into an intermediate or temporary table and filter the data according to your need. You can add another column which gives you the line number in the excel sheet.
ASKER
I will try this solution but I'm trying to not use a reference to the excel objects as this could tie me into a particular version of excel. Is there a way to use an excel connection string then export the data directly to a SQL table using a SQL command?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solution guided me to the answer. Thanks.
http://vb.net-informations.com/excel..._open_file.htm
http://vb.net-informations.com/excel..._worksheet.htm
The SQL-part
http://www.developerfusion.com/article/4278/using-adonet-with-sql-server/
on page 3 (article continues) you see an UPDATE as on how your insert should be written