I'm trying to update table into an .accdb file by a C# program.
I've opened the connection in this way:
cn.ConnectionString= #"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\test.accdb;Persist Security Info=True;Database Password=myDb";
cmd.Connection = cn;
string query = "UPDATE MY_TABLE SET NOTE='TEST'";
cmd.CommandText = query;
cn.Open();
but I get this error:
Could not find installable ISAM
I also installed the AccessDatabaseEngine x86, but nothing happened.
Any suggestions?
Thanks!
“Could not find installable isam” is a bit of a generic catch all, usually connection string or driver bitness related. For connection strings that use extended properties like Database Password they may need to be prefixed with something to make it assigned as an extended property of that particular driver
In your case I think you’re missing the relevant specifier for the database password property, which isn’t a typical OLE connectionstring property:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\test.accdb; Jet OLEDB:Database Password=MyDbPassword;
Note the extra “Jet OLEDB” before the database password specifier
connectionstrings.com has a raft of info for these things and serves as a handy resource for many different thins that Jet and Ace can connect to
Related
I am trying to conncet access database to my visual studio but i face this type of error "The Microsoft.ACE.OLEDB.12.0" provider is not registered on the local machine.
I look at some solutions on google i got that after downloading Microsoft Access Database Engine on Local machine we are able to connect database.But i still face this problem. So What should i do for it? .And i am using Windows10 but i use Ms office 2007 and my system is 64-bit.enter image description here
You don't mention if you planning to use the x32 bit or x64 version of access.
So, assuming you downloaded the access data engine? You have to choose or decide WHICH bit size version you wish to use.
That download can be found here:
https://www.microsoft.com/en-ca/download/details.aspx?id=13255
And you have two choices:
Ok, next up?
You MUST set and FORCE your project to the correct bit size.
that is this project setting in VS.
So, if you using x32 version, then use x86 version, and if adopting x64 version, then set your project to x64.
So, don't use "any" for your project setting - you have to force the issue.
So, try setting up a connection. You have two choices:
Use the ODBC provider,
or
Use the oleDB provider
So, ok, ODBC? then that connection setting should look like this:
For odbc, the connecton string should look like this:
Driver={Microsoft Access Driver (*.mdb, *.accdb)};
dbq=C:\TEST\test444.accdb;uid=Admin
for oleDB, the connection string should look like this:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\test\test45.accdb
And in both cases, you can as a normal rule, leave the password blank.
Assuming you used the project settings, say here:
(and you can use the connection string builder in above. BUT BE VERY carefull, if you are running access x64, then the test connection WILL ALWAYS ALWAYS fail, since VS is a x32 bit applcation, but if you run your code, and the project was forced to x64 bits, then the connection will work DISPITE VS and the test connection telling you it does not.
So, to use the above ODBC connection, we have this:
using (OdbcConnection conn = new OdbcConnection(Properties.Settings.Default.AccessODBC))
{
string strSQL =
"SELECT * FROM tblHotels ORDER BY HotelName";
using (OdbcCommand cmdSQL = new OdbcCommand(strSQL, conn))
{
conn.Open();
DataTable rstData = new DataTable();
rstData.Load(cmdSQL.ExecuteReader());
dataGridView1.DataSource = rstData;
}
}
And for oledb, we would have this:
using (OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.AccessDB))
{
string strSQL =
"SELECT * FROM tblHotels ORDER BY HotelName";
using (OleDbCommand cmdSQL = new OleDbCommand(strSQL, conn))
{
conn.Open();
DataTable rstData = new DataTable();
rstData.Load(cmdSQL.ExecuteReader());
dataGridView1.DataSource = rstData;
}
}
So, which provider to use?
Most use and suggest oleDB.
However, I think using ODBC is not all that bad of a choice. the reason is you can change the connection to sql server, or other database systems, and NOT have to change your provider, but only the connection string.
While you can sort of do the same with oleDB, there is now MUCH better support for ODBC database systems.
I've written this simple connection in my code:
OracleConnection con = new OracleConnection("Data Source=ORCL;User
ID=agapus;Password=agap");
con.Open();
Then I run my application pressing F5 and I get the above error. This error occurs no matter if it's just a simple console app or an ASP.NET web site. I've tried both Oracle.DataAccess and the old windows oracle API. I've tried several Oracle services, all with no luck.
The environment where I'm testing this connection is a Windows Server 2008R2. I can easily connect to any database using SQLPlus or TOAD. I've tried explicitly specifying the location of the TNS_NAMES.ORA file, doesn't work either.
The only thing that works is when I specify the full path in the connection string. So if I change the above code into the below one, it'll work:
string conString = "user id=agapus;password=agap;data source=(DESCRIPTION=(ADDRESS=
(PROTOCOL=tcp)(HOST=172.16.0.121)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))";
ID=agapus;Password=agap");
OracleConnection con = new OracleConnection(conString);
con.Open();
If you look in your sqlnet.ora file, I believe that you will find that the default domain is set to .world .
That would make the correct name of your connection ORCL.world .
You may also have .world on the end of your connection name in TNSNAMES.ora, and nothing for the default domain.
What do you get when you run tnsping?
I have written a program in C# to pull some data using OdbcConnection :
using System.Data.Odbc;
......
OdbcConnection OdbcConn =
new OdbcConnection(Properties.Settings.Default.ConnectionString);
OdbcCommand cmd = new OdbcCommand();
//open connection
if (OdbcConn.State != ConnectionState.Open)
{
OdbcConn.Open();
}
In my settings file, I have this ConnectionString:
Dsn=****;uid=userID;pwd=password
However I cannot establish a connection. I have an iseries access driver from IBM corp installed, but if I try MS access then I am able to connect. Any suggestions?
When in doubt (and it involves connections strings): http://www.connectionstrings.com/
On a Windows 64 bit machine, make sure you check if your C# code is compiled in x86 (32-bit), x64, or "Any CPU". Note that if you compile as "Any CPU," it'll choose x64 bit drivers by default.
The 32-bit drivers can be found at C:\windows\SysWOW64\odbcad32.exe. The 32-bit drivers can be found at C:\windows\system32\odbcad32.exe.
First, make sure you verify your connection works with the ODBC Data Source Administrator using the paths I provided earlier. I.e. make a DSN and test it as Turbot suggested. Once you verified this connection works, your connection string can either use the DSN you just created or you can use a DSN free connection string.
For a quick reference, here is a sample of a DSN free connection string using a ODBC driver:
Driver={Progress OpenEdge 11.3 Driver};HOST=wfdscr11.wf.local;Port=1234;DB=MyDatabaseName;UID=John;PWD=Doe
In this example, I had to connect to a Progress database from my C# code and this is the connection string I used without having to specify a DSN. You can see below that the name of the driver is "Progress OpenEdge 11.3 Driver."
I always like to verify the connection using Data source(ODBC) in control panel (assume you are in window environment). Make sure you see the drive available in your ODBC selection and follow the steps to test the connectivity.
as also mentioned above the connections strings website would give you idea what properties and format on which particular driver connectivity
Is there a way to protect a *.sdf (sqlCE file) with a password or implement a similar security measure?
i try this:
if (!File.Exists(SDK))
{
SqlCeEngine engine = new SqlCeEngine("Data Source=" + SDK + "; Case Sensitive=True");
engine.CreateDatabase();
OpenConn();
SqlCeCommand CMD = new SqlCeCommand();
CMD = Conn.CreateCommand();
CMD.CommandText = "Create table MEN(Code int ,Fname nvarchar(50),Lname nvarchar(50))";
CMD.ExecuteNonQuery();
}
where to change to have password ?
Since SQL CE 2000 password protection is possible:
CREATE DATABASE "secure.sdf"
DATABASEPASSWORD '<enterStrongPasswordHere>'
more here and here
The Visual Studio 2010 extension SQL Server Compact Toolbox can be used to create a database with a password. Encryption of the database is handled automatically once the password is set. The only catch is you need to create a new database with a password using the extension; it cannot password protect existing .sdf files. If you need to keep your existing structure: backup your data and/or schema, and reapply to the new one.
A layered approach, like most security solutions, is typically best and can be applied here. It is important to check (and correct) the encryption state of the file on the operating system level as well. You could even go above and beyond by encrypting the actual .sdf file inside of your run-time.
A good article on that here.
Cheers
Depending on what kind of protection you are looking for, you can password protect your database as well encrypt it.
If you're going to take advantage of either of those options, I believe you have to create the database in SQL Server Management Studio rather than letting Visual Studio create one for you. Take a look at the following page for instructions (page is for Sql CE 4 but should apply to other versions as well):
Dean Hume - A Simple Guide to SQL Compact 4
hey,
i am new at connecting to dataBases and for some reason each time i use those following lines my program collapse:
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=|DataDirectory|\Company.accdb"
OleDbConnection con = new OleDbConnection(connectionString);
inside my debug folder i got Company.accdb access file
edit:
i am getting 'Microsoft.Ace.OLEDB12.0' provider is not registered on the local machine any idea how to solve it?
thanks in advance for your help
Two things -
This connection string rely on ACE OLEDB provider (typically comes with Office 2007 - your machine need to have this provider)
Connection string is requesting data dictionary. You probably need to use below form:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;
For password protected files, form would be Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;
I will also suggest trying different Provider (ODBC perhaps) instead. For various connection strings for Access 2007, refer http://www.connectionstrings.com/access-2007