Excel and third party add ons

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
I have been trying to access an Excel spreadsheet through the 'normal' MS + VB.NET way to no avail.

My latest error is from this line of code:

VB.NET:
Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("SELECT INTO [ODBC;Driver={SQL Server};Server=(.\SQLEXPRESS);" & _
"Database=GRS;Trusted_Connection=yes].[PO] FROM [Sheet1$];", _
ExcelConnection)

ExcelCommand.ExecuteNonQuery()

I get an error saying either a reservered word is being used or there is a punctuation error etc etc.

I tried changing (.\SQLEXPRESS) to (local) but go the same.

I then found a plug in by GemBox at http://www.gemboxsoftware.com/GBSpreadsheetFree.htm

Which let me access the file I need fist go!

However although this control restricts the row import to 150, I will never need more than 20, it is not a desired way to go.

It would I feel be vulnerable to future PC updates and not supported as it is free. My employer will not pay the hundreds need for licenced product as we only want to reads in 20 rows.

So I am reverting to the Microsoft approach which must be obvioulsy workable but at present I cannot see it!

Can anyone give me some pointers or tell me where in my code above I have foolishly gone wrong?

Thx
 
Back
Top