ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import from Excel to an access database using Jet in vb.net (https://www.excelbanter.com/excel-programming/405721-import-excel-access-database-using-jet-vbulletin-net.html)

Andy HP[_2_]

Import from Excel to an access database using Jet in vb.net
 
I can import data from Excel to a non protected access database using the
code below.
How can I amend the code to import the data when 'myDatabase' is password
protected ?

Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
source=myExcelFile;Extended Properties='Excel 8.0;HDR=YES;'"
Comm.CommandType = CommandType.Text
Comm.CommandText = "SELECT * INTO tblNew IN 'myDatabase' FROM [Sheet1$]"
Comm.Connection = Conn
Conn.Open()
Comm.ExecuteNonQuery()
Conn.Close

Liew Yew Hwa

Import from Excel to an access database using Jet in vb.net
 
how u declare 'MyDatabase' is a proper way?
It will have the error if u just simply write 'MyDatabase' inside the code because it have not state the path of location of the database. can show me the full coding? thanks!

On Thursday, February 07, 2008 4:04 AM AndyH wrote:


I can import data from Excel to a non protected access database using the
code below.
How can I amend the code to import the data when 'myDatabase' is password
protected ?

Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
source=myExcelFile;Extended Properties='Excel 8.0;HDR=YES;'"
Comm.CommandType = CommandType.Text
Comm.CommandText = "SELECT * INTO tblNew IN 'myDatabase' FROM [Sheet1$]"
Comm.Connection = Conn
Conn.Open()
Comm.ExecuteNonQuery()
Conn.Close



Submitted via EggHeadCafe
Stock Quotes via jQuery-enabled WCF Service, JSON, and jQuery Templates
http://www.eggheadcafe.com/tutorials...templates.aspx



All times are GMT +1. The time now is 02:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com