pondělí 27. prosince 2010

Práce s MySQL v C# (Visual Studio)

using MySql.Data.MySqlClient;


MySqlCommand cmd = new MySqlCommand();
MySqlConnection connect = new MySqlConnection("Address=localhost;Port=3306;Database=pokus;" +
            "UserId=root;Password=heslo");
try
{
connect.Open();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadKey();
return;
}
cmd.CommandText = "INSERT INTO `pokus`.`logy` ( `URL`, `Title`, `ModifiedDate` ) VALUES ('" +
    enumerator.Current.URL + "', '" + enumerator.Current.Title + "', '" + LastVisited + "');";
cmd.Connection = connect;
cmd.ExecuteNonQuery();
connect.Close();

Žádné komentáře:

Okomentovat