The System.Data.SqlClient
(reference here) is exclusive to SQL Server(as in this LINQ response). Without a third-party DLL it is almost impossible to connect.
According to my searches there are other ways to connect MYSQL to c# and is not exclusive to MySql.Data.dll
. On that website found some connector options for . NET:
I believe that the MySQLDriverCS
is the most used, the rest should no longer be used in the market (difficult to find references). Follow example using the MySQLDriverCS
found at that link.
using MySQLDriverCS;
using System.Data;
MySQLConnection myConn;
MySQLDataReader MyReader = null;
try
{
myConn = new MySQLConnection(new MySQLConnectionString("123.456.789.100",
"mydatabase",
"user",
"pass").AsString);
myConn.Open();
string sql = "SELECT * FROM Table";
MySQLCommand cmd = new MySQLCommand(sql, myConn);
MyReader = cmd.ExecuteReaderEx();
while (MyReader.Read())
{
Console.WriteLine( MyReader["Product_Name"].ToString() );
}
MyReader.Close();
}
catch(Exception ee)
{
Console.WriteLine( ee.ToString() );
}
finally
{
if (MyReader != null && !MyReader.IsClosed)
{
MyReader.Close();
}
if (myConn != null && myConn.State == ConnectionState.Open)
{
myConn.Close();
}
}
From what I understand is VERY MUCH similar to the MySql.Data.dll
.
There’s always, I can’t tell the size of juggling to get.
– Maniero
@Bigown knows at least where I should start?
– Francisco
The problem is just this, it has many forms spread.
– Maniero