C# MySQL Connector works in IDE, not after publish? - c#

For some reason I can't seem to get the MySQL Net Connector to work with C# outside of the IDE. I have a very simple program working just fine in the IDE (connecting to the database and everything) but when I publish the code and run the .application file (on my local computers desktop or off the company server) it says it can't connect to any of the specified MySQL hosts.
Any help would be greatly appreciated! :(
Thank you

I would double check all your references, and make sure you have the MySQL Net Connector in the GAC.

Check that the MySQL provider is properly declared in the machine.config file (in the DbProviderFactories element). You can also declare it in the web.config instead

Related

How to Run C# application that uses MySQL on another PC?

I know this subject was discussed here before, but it looks like there are several opinions.
My C# App is connected to a Database using MySQL, I created an installer for it and tried to run it on another PC.
The program didn't work.
How can I make it run on others PCs?
How to include the MySQL Database with my installation package?
If I used the localDatabase in visual Studio 2013 instead of MySQL will this solve my issue and make the application run on other PCs?
When I use the localDatabase; a (*.mdf) file is copied to the debug folder, if I just included this file in the installation package, will it be enough?

ORA-12557 TNS:protocol adapter not loadable

I am trying to develop a C# Windows Forms Application targeting the .net 4 framework. The program will execute a stored procedure against an Oracle Database and I get the following error when I try to open the connection to the database.
ORA-12557 TNS:protocol adapter not loadable
I am developing this in Visual Studio 2012 and have managed to make the Server Explorer connect to the database successfully, however I keep getting this error through my application.
I have two Oracle 11g clients on my machine. One is 32bit and the other is 64bit. I do need both for different applications so it is not possible to remove one. I have also tried changing the order of the Oracle home directories in the PATH variable. Currently I have the 64bit one first which is the one I would like to connect with.
I am connecting my application to the Database using ODP.NET and have referenced the dll from the 64bit application.
As far as I can tell I have done what has been suggested and have not managed to get it working. If anyone could help it would be appreciated.
The ORA-12577 error is related to Windows Environment or Oracle Home PATH because sqlplus command works smoothly when I execute it inside ORACLE_HOME\bin .
Its because of two or more oracle installs (say database and companion) in separate ORACLE_HOMEs on that machine unset the ORACLE_HOME value in your window
For Details please follow the following steps and hope so you will get the solution.
http://www.dba-oracle.com/t_ora_12577.htm
The base problem is that there are DLLs missing in the Oracle instant client installation that exist in the RDBMS server installation that the application requires. This is why switching Oracle homes from client_1 to db_1 works, rather than it being a purely a PATH problem.
sqlplus works in either situation because it uses the minimal set of DLLs which exist in both Oracle installations.
Here are a few things to check. Dont forget to try #3 if needed, it fix the problem for me!
Make sure all Oracle services are started
Make sure environment variables are set (PATH, ORACLE_SID=ORALOCAL, TNS_ADMIN=C:\Dev\Oracle\product\11.2.0\dbhome\NETWORK\ADMIN)
Try shifting the Path environment variable values like so:
“D:\Dev\Oracle\product\11.2.0\dbhome\bin” to be before the
“D:\dev\Oracle\product\11.2.0\client_32\bin” in the order
Fissh
For me I am using IIS .net provider. I was able to fix the problem with sqlplus by putting oracle64 before oracle32 in the path. This did not fix problems with .net. I have apps that use oracle32 and oracle64. To solve this problem registry keys HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE must point to \oracle32 home and HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE must point to the \oracle(64) home.

IBM db2 driver deployment / installation

I'm trying to connect to IBM DB2 database with C# application. At first I've installed IBM Data Server Driver Package, which, according to the documentation is for applications using ODBC, CLI, .NET, OLE DB, PHP, Ruby, JDBC, or SQLJ, use IBM Data Server Driver Package. Then I thought I could use IBM.Data.DB2 assembly and happily connect. It didn't work at all, as the app kept crashing while looking for db2app.dll in its current working directory.
Then I installed IBM Data Server Client, which has this dll in "bin" directory, which I added to system path. That didn't help, so I copied it to my app's build directory, and it now works. But I don't think that is correct, as I also had to copy msg\en_US\db2nmp.xml file to my build directory to get exception error texts.
I think it's wrong to copy all these files from DB2 installation, and I should somehow be able to force IBM.Data.DB2 assembly to look for its required files in the system path, not in its working directory. I also think that Data Server Driver Package should be enough, but I wasn't able to do anything with IBM.Data.DB2.dll until I installed the larger Data Server Client.
I assume that the problem is on my end, not with IBM, so I'm doing something obviously or subtly wrong.
My question is: How do I use the smaller IBM Data Server Driver Package with .NET application?
I think you are looking for this information that is available in DB2 manual:
http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.swg.im.dbclient.adonet.doc/doc/c0010960.html
And perhaps this helps also:
http://www.ibm.com/developerworks/wikis/display/DB2/DB2%20and%20.NET%20FAQs#DB2and.NETFAQs-WherecanIfindtheDB2.NETproviderandVSAddins%3F
In general, I think you should've installed IBM Database Add-Ins for Visual Studio from here(Requires IBM Registration):
https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=swg-daivs

Including MySQL Connector/ODBC 5.1 to C# application

I am using System.data.odbc with "Driver={MySQL ODBC 5.1 Driver}" in the connection string. However, I have not realised there is MySQL connector installed on my PC so however I have not referenced it, it doesn work without it.
Now I need to distribute it embed in the app. I have downloaded MySQL Connector/ODBC 5.1 files, but with Add reference it says "The file is not accessible...make sure its valid COM.." etc.
Thank you
MySQL Connector/ODBC is, as the name suggests, just an ODBC driver for connecting to MySQL. It's not specifically designed for .NET and you can't embed it in your .NET applications in any way. It will need separate installation on any machine where you need to use it.
MySQL Connector/Net is a fully managed ADO.NET provider for MySQL. It's tailor-made for .NET and doesn't require the installation of any other software. It's easy to reference and distribute in your .NET applications, you'll just need to use the System.Data.MySqlClient namespace and objects rather than System.Data.Odbc.
You can embed the .NET DLL, but not the driver itself. You'll need to install MySQL Connector on every computer that runs your application.
The only thing u need is Mysql.Data.Dll
You don't need to install the complete connector, everything u need is in there.
That also counts for the end user, they also only need the dll

Cannot add connection to MySQL in C# application

I am trying to connect MySQL to Windows following the instructions given here.
I have installed MySQL 5.1 software, GUI tools and MySQL connector. MySQL is working fine.
I want to establish connection between the MySQL database and a C# Windows application.
But I am not able to find "MySql.Data" in add references tab in the C# Windows application. Can anyone help me to solve this issue?
Please refer to the screenshot below:
If you really have the Connector/NET installed, it ought to show up in the .NET tab.
If not you can just click the Browse tab, and add the assembly directly, it should be under
C:\Program Files\MySQL\MySQL Connector
Net 6.0.4\Assemblies
or somesuch.
How about browsing to the DLL (browse tab)?

Categories

Resources