I was always connecting to SQL which was simple, but now I would need to connect to a MySQL server. I thought System.data.odbc connection will work, but it doesnt connect. I do not udnerstand whather I really need to download and install any third party stuff like Connector or even MyODBC, I thought ODBC in .NET is enough. Could you please advice?
So far I am using:
string ConString = #"driver={MySQL ODBC 3.51 Driver};server=localhost;database=db;uid=band;pwd=letmein;";
dbconn.ConnectionString = ConString;
dbcon.Open();
Thank you in advance.
There are various possibilities to connect to a MySQL database. A list of them (and the necessary connection strings) can be found on this excellent site: http://www.connectionstrings.com/mysql
Edit: Since you're trying to avoid third-party connectors (even though I recommend them, because they were written specifically for the target db), you should look out for ".NET Framework Data Provider for OLE DB" or ".NET Framework Data Provider for ODBC" in the list
You need either a odbc driver for MySQL or a .Net Framework Class to use (ie MySql.Data.MySqlClient.MySqlConnection)
.Net and Windows doesn't include native support for MySQL
Related
I have a project in which I need to get data a Database that is on Sql Anywhere v9, searching in Google I cant find to much information because its an old version(and I/the client cant upgrade the version of the database), in the few documents that I could find mention a .Net Driver but the links are broken. Anyone know if this Driver is the only way Or if there is another way to connect?
Have you tried creating an ODBC connection and talking to the database via ODBC?
ODBC Tutorial
Download and install any version of SQL Anywhere Developer Edition even if it's a newer version. They are free. This will contain all the .NET data providers and drivers. In my experience newer versions of the Sybase client can connect to older DB Servers.
You then have to make sure you get the connection string right to connect with C#.
I'm using C# to connect to a version 10 server, here is the connection string I found that works for me:
Provider=SAOLEDB;LINKS=tcpip(host=1.2.3.4,PORT=123;DoBroadcast=None);ServerName=SQLANYWHERE9;Integrated Security = True; User ID = database; PWD = password
What is the data provider for nhibernate? Is it ADO.NET?
Yes it uses ADO.NET internally.
Take a look at http://community.jboss.org/wiki/DatabasesSupportedByNHibernate.
It shows what tools/drivers are used to connect to different databases. for example:
Oracle 9i and 10g are supported, both using Microsoft driver (System.Data.OracleClient) and using Oracle driver (Oracle.Data.OracleClient).
Or:
To work with Firebird, install the latest Firebird .NET Data Provider.
I'm not sure whether it uses ADO.Net for SQL Server connections under the hood, But it seems that it doesn't use ADO.Net for other database systems.
What is the best library/driver to connect C# (.NET) application to Oracle 10g and 11g.
Current options that I found are:
Oracle client that comes with database installation
Oracle Instant Client (which is a bit confusing since it has 6-8 versions for number of operating systems)
Microsoft ODBC ? (Can this be used?)
ODP.Net - is this separate product or is it included in 1. and 2. ?
Can somebody explain differences?
I am planning C# application that will do basic CRUD operations on Oracle database. Which library/driver is smallest and easiest to install?
Edit:
General recommendation is to use ODP.Net. Now, can somebody please explain or point to answer about differences between client install packages. I found 3 different clients for Oracle 11g:
Oracle client - client drivers package that ships as part of database installation
ODAC - Oracle data access components, contains lots of things, among them are ODP.Net and Oracle Instant Client
Oracle Instant Client which also contains many things, including ODP.Net
So, which of those is enough for development? Oracle documentation is painfully detailed, but says nothing about differences between those client packages. I would go with smallest (Instant Client). Is it best choice?
Edit 2:
I am using .Net 3.5
Microsoft will deprecate the System.Client.OracleClient namespace so I think it will be best to use ODP.NET. Make sure you download the latest one (ODP.NET 11g) as previous versions had some issues.
To connect C# to oracle you need a data provider for .net. This can be one of the following:
ODP.Net (Oracle)
System.Data.OracleClient (Microsoft)
ODBC (Oracle)
OLEDB (Oracle)
DataDirect ADO.NET Data Provider for Oracle (DataDirect)
may be some other provider
All of this data provider need an oracle client installed. There is no standalone library as jdbc14.jar as in java. You have 2 choices deploying an oracle client:
full client (may be from database installation)
instant client
ODP.Net, ODBC, OLEDB are part of full client. This is the "hard" way because an installation process must be run on every client runing your software. This is where the most megabytes are put on the client.
The instant client is provided in different packages. This is the smallest way for deployment of an oracle client.
I would suggest using ODP.Net with Oracle Instant Client, because this easy to deploy and very very light weight.
Which instant client packages do you need:
Pick version 11.1.0.6.0 (or newer where ODAC is provided)
Instant Client Package - Basic (if you need full language support)
Instant Client Package - ODAC
There are a lot of articles on stackoverflow about deployment of oracle instant client with c# applications.
EDIT: updated links and versions
ODP.NET is the best provider for accessing Oracle db, mostly - because it's the most native one, which differentiates it from ODBC by the following:
better performance
ODP.NET provides access to advanced Oracle functionality, not available via ODBC .NET
ODP.NET does not use an extra data access bridge.
ODBC can also be used but as mentioned above it's going to be slower and have limited functionality.
For making ODP.NET work you need the software listed here (and including oracle client):
http://www.oracle.com/technology/tech/windows/odpnet/faq.html#install
Hope this helps!
Maybe I'm wrong but ADO.NET have integrated support for Oracle. maybe for earlier versions...
I think odbc is too slow. System.Data.OracleClient is a bit slow too and it will be deprecated by Microsoft.
You could use devart's provider, there is a free version. It is easy to deploy. See here http://www.devart.com/dotconnect/oracle/ It does support the entity framework.
Odp.net is fast but it doesn't support the entity framework and it isn't very easy to deploy.
I really cannot say the differences between the solutions you provided but I always used the Oracle Data Access Components from Oracle and it always worked flawlessly. It could be found here : ODAC for Visual Studio
What is sure is that a library developped by Oracle on the .NET Framework will be much more accurate than a library developped by an company external to Oracle. For example, concerning exceptions thrown when accessing an Oracle database, they will be much more helpful if the library have been developped by the Oracle developping team as they have additional knowledges on Oracle DBs.
The bad thing is that you will have a dependency, problem that you will not have to overcome if you chose to use the .NET System.Data.OracleClient.
Hope this helps. Regards.
EDIT : The ODAC package contains ODP and Oracle Developer Tools
ODP.NET is a native provider fo accessing oracle db. And hence it should be better optimized for oracle db. Moreover, there are oracle feature, such as REF CURSOR type, which are not supported by MS ODBC, but supported by ODP.NET. You can download ODAC, which include ODP.NET as well, on the www.aracle.com website.
pls suggest how to configure 10g and which type of connection strings are supplied to c#.net.
thanks.
Download and install ODP.NET Oracle data access components. It has everything you need. it will just take TNS and user/password to connect. It similar to System.Data.SqlClient but design by oracle for .NET users. For connection string read
I am trying to figure out what is the best way to connect an (existing) ASP.Net application to an Oracle database to read its dictionary information.
There are simply too many possibilities:
MS Data Provider for Oracle (requires 8.1.7, namespace System.Data.OracleClient)
Oracle Data Provider for .NET (requires 9.2, namespace Oracle.DataAccess)
Oracle Provider for OLE DB
MSDASQL and ODBC
As my current app uses MSSQL server, further options would be:
Linked Server, access via server..user.object
Linked Server via OPENROWSET
There are a couple of questions on similar topics on SO, but only some have accepted answers.
What's your experience with each of the drivers? What are their pros and cons?
Of course Oracle is recommending ODP.Net. Is the requirement of version 9.2 (or higher) a problem today?
I too recommend ODP.NET. Choose the latest provider (http://www.oracle.com/technology/tech/windows/odpnet/index.html). It can connect with an Oracle 9.2 database or a newer release of the database.
The MS Data Provider for Oracle is very limited. You can't work with arrays for example and user defined types. And why would Microsoft provide good support for connecting to Oracle?
You can also check out the provider of devart: http://www.devart.com/dotconnect/oracle/ . It supports the entity framework.
Dump OLE DB and ODBC options, if you have direct data access provider there is no need in using OLE DB or ODBC.
I recommend Oracle Data Provider for .NET.
Microsoft just announced it is deprecating System.Data.OracleClient.
I think that leaves you with a few choices (at least):
ODP.NET (free, from Oracle)
DevArt
DataDirect
DevArt also has a LINQ to Oracle implementation which could be interesting to you.