Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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, it's 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 won't 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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...