mioku b984782e6c 定时同步 | 7 months ago | |
---|---|---|
.. | ||
lib | 7 months ago | |
runtimes | 7 months ago | |
.signature.p7s | 7 months ago | |
MySql.Data.8.3.0.nupkg | 7 months ago | |
README.md | 7 months ago | |
logo-mysql-170x115.png | 7 months ago |
MySQL provides connectivity for client applications developed in .NET compatible programming languages with MySQL Connector/NET through a series of packages.
MySql.Data is the core package of Connector/NET. It is compatible with .NET Framework 4.6+ and .NET 6.0+ and provides classic MySQL protocol and MySQL X DevAPI capabilities.
More information at MySQL Connector/NET documentation.
MySql.Data.MySqlClient.MySqlConnection myConnection;
string myConnectionString;
//set the correct values for your server, user, password and database name
myConnectionString = "server=127.0.0.1;uid=root;pwd=12345;database=test";
try
{
myConnection = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
//open a connection
myConnection.Open();
// create a MySQL command and set the SQL statement with parameters
MySqlCommand myCommand = new MySqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = @"SELECT * FROM clients WHERE client_id = @clientId;";
myCommand.Parameters.AddWithValue("@clientId", clientId);
// execute the command and read the results
using var myReader = myCommand.ExecuteReader()
{
while (myReader.Read())
{
var id = myReader.GetInt32("client_id");
var name = myReader.GetString("client_name");
// ...
}
}
myConnection.Close();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
MessageBox.Show(ex.Message);
}
There are a few ways to contribute to the Connector/NET code. Please refer to the contributing guidelines for additional information.
#connectors
channel in MySQL Community Slack (Sign-up required when not using an Oracle account)