Reputation:
I have used the connection string below but I am getting an error when trying to create a table
Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFName + _ ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""
Cannot modify the design of table 'tablename'. It is in a read-only database.
Upvotes: 0
Views: 3280
Reputation: 11
Make absolutely certain that you do have write access to the file. For example are you accessing this from IIS which only has limited permissions. Check the security of the directory. Try a normal File.Open() of the file in the same process.
Upvotes: 1
Reputation: 2441
Your problem is the IMEX=1. That tells excel to open in "import mode" making the connection read-only. I had the same issue, weird weird stuff.
Take that out and it works like a charm.
Upvotes: 0
Reputation: 12288
I'm personally using the following to connect to an access database:
_source = "..\db.mdb"
Dim strconnexion As String
strconnexion = "Provider=Microsoft.Jet.OLEDB.4.0;"
strconnexion &= "User ID=Admin;Password=;"
strconnexion &= "Data source=" & _source
_cnBd = New OleDbConnection (strconnexion)
_cnBd.Open()
Hope this helps.
Upvotes: 0
Reputation: 300489
If the database is read-only, then by definition you will not be able to create any tables in it.
Upvotes: 1