SqlException while Connecting to mySQL

  • Thread starter Thread starter Cindy
  • Start date Start date
C

Cindy

Dear Group,

I have a C# client connecting to a remote mySql database and I'm
getting the following exception:

Unhandled Exception: System.Data.SqlClient.SqlException: SQL Server
does not exi
st or access denied.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransactio
n)
at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConn
ectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at MainClass.Connect() in e:\NET\db\dbaccess\Main.cs:line 35
at MainClass.Main(String[] args) in e:\NET\db\dbaccess\Main.cs:line
65

This is what my my connect method looks like:

SqlConnection sqlCon = null;
string conStr1 = "Data Source=" + ipAddress +
" ; Database=hightechzen" +
" ; User ID=userid" +
" ; Password=password";
sqlCon = new SqlConnection(conStr1);
sqlCon.Open();

This is my namespace definition:

using System.Data;
using System.Data.SqlClient;

Using a mySql client UI (navicat), I can connect to mySql. So my
machine is setup for access. What do I need to do in my c# client to
connect.

Thanks in advance,

Cindy
 
Hi Cindy,

Try with this connection string:
workstation id=***;packet size=4096;user id=***;data
source=YourDataSource;initial catalog=Northwind;persist security
info=True;password=***

If you pass an IP address as datasource, make sure it is within parenthesis:
data source="10.0.0.1";
 
You can't connect to a "mySQL" database using the SqlClient which uses the
native provider for SQL Server.
You have to use the classes in whichever ADD-ON you choose that exposes a
provider for MySQL.
One of such addons is for example MySQLDirect.NET available at
http://crlab.com/mysqlnet/

Remember Classes in the System.Data.SqlClient are only good to access data
in a Microsoft SQL Server instance (7 & Above).

Hope this helps,


Guillermo Salas
Milwaukee, WI


Dear Group,

I have a C# client connecting to a remote mySql database and I'm
getting the following exception:

Unhandled Exception: System.Data.SqlClient.SqlException: SQL Server
does not exi
st or access denied.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransactio
n)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConn
ectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at MainClass.Connect() in e:\NET\db\dbaccess\Main.cs:line 35
at MainClass.Main(String[] args) in e:\NET\db\dbaccess\Main.cs:line
65

This is what my my connect method looks like:

SqlConnection sqlCon = null;
string conStr1 = "Data Source=" + ipAddress +
" ; Database=hightechzen" +
" ; User ID=userid" +
" ; Password=password";
sqlCon = new SqlConnection(conStr1);
sqlCon.Open();

This is my namespace definition:

using System.Data;
using System.Data.SqlClient;

Using a mySql client UI (navicat), I can connect to mySql. So my
machine is setup for access. What do I need to do in my c# client to
connect.

Thanks in advance,

Cindy
 
Back
Top