Hello,
I use Visual Basic .NET 2008 and want to create a new Excel workbook and save data into it...
I was using this code for Excel 97-2003 workbooks and it just works fine:
---
Dim ExcelString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileTextBox.Text + ";Extended Properties=Excel 8.0;"
Dim ExcelConnection As New OleDbConnection(ExcelString)
ExcelConnection.Open()
Dim ExcelCommand As New OleDbCommand()
ExcelCommand.Connection = ExcelConnection
ExcelCommand.CommandText = "CREATE TABLE Sheet1 (Email Char(255))"
ExcelCommand.ExecuteNonQuery()
ExcelCommand.CommandText = "INSERT INTO Sheet1 (Email) Values (" + MyReaders("Email").ToString + ")"
ExcelCommand.ExecuteNonQuery()
ExcelConnection.Close()
---
However, its old, now I wanna to save data in Excel 2007 format with .xlsx extension.
So I update my connection string like this:
---
Dim ExcelString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileTextBox.Text + ";Extended Properties=""Excel 12.0 Xml;HDR=NO;IMEX=1"""
---
But it wont work anymore!
I get this error now:
The Microsoft Office Access database engine could not find the object ...(filepath+name)... Make sure the object exists and that you spell its name and the path name correctly.
Please help me what should I do now?
Thanks.
I use Visual Basic .NET 2008 and want to create a new Excel workbook and save data into it...
I was using this code for Excel 97-2003 workbooks and it just works fine:
---
Dim ExcelString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileTextBox.Text + ";Extended Properties=Excel 8.0;"
Dim ExcelConnection As New OleDbConnection(ExcelString)
ExcelConnection.Open()
Dim ExcelCommand As New OleDbCommand()
ExcelCommand.Connection = ExcelConnection
ExcelCommand.CommandText = "CREATE TABLE Sheet1 (Email Char(255))"
ExcelCommand.ExecuteNonQuery()
ExcelCommand.CommandText = "INSERT INTO Sheet1 (Email) Values (" + MyReaders("Email").ToString + ")"
ExcelCommand.ExecuteNonQuery()
ExcelConnection.Close()
---
However, its old, now I wanna to save data in Excel 2007 format with .xlsx extension.
So I update my connection string like this:
---
Dim ExcelString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileTextBox.Text + ";Extended Properties=""Excel 12.0 Xml;HDR=NO;IMEX=1"""
---
But it wont work anymore!
I get this error now:
The Microsoft Office Access database engine could not find the object ...(filepath+name)... Make sure the object exists and that you spell its name and the path name correctly.
Please help me what should I do now?
Thanks.