Simply.com is available in english

Kapcsolat a MySQL-hez .NET Connectorral

Az alábbi kódrészlet használható a MySQL adatbázishoz való hozzáféréshez a MySQL .NET Connectoron keresztül:

A MySQL illesztőprogramot saját maga telepítheti a webtárhelyére, letölthető a MySQL weboldaláról.

using MySql.Data.MySqlClient;

MySqlConnection con = new MySqlConnection();
string mysql = "Server=[server];Database=[database];User=[brugernavn];pwd=[password]";
con.ConnectionString = mysql;
con.Open();

MySqlCommand cmd = con.CreateCommand();
cmd.CommandText = "SELECT * FROM TestTabel";
cmd.Connection = con;

MySqlDataReader reader = cmd.ExecuteReader();

while (reader.Read())
{
Response.Write(reader.GetValue(0).ToString());
}

cmd.Dispose();
con.Close();

Cikk a támogatási kategóriából: ASP & ASP.NET

Egyéb releváns cikkek