0
phpmyadmin mysql數據庫如何將數據保存到xampp從Windows窗體應用程序c#phpmyadmin mysql數據庫?數據變量是country1,city1,temperature1。 數據庫是天氣和表預計如何將數據保存到xampp從Windows窗體應用程序c#
try
{
string MyConnection2 = "datasource=localhost;port=3307;username=db1;password=db12121";
string Query = "insert into weather.forecast(country, city, temperature) values('" + country1 + "','" + city1 + "','" + temperature "');";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataReader MyReader2;
MyConn2.Open();
MyReader2 = MyCommand2.ExecuteReader();
MessageBox.Show("Save Data");
while (MyReader2.Read())
{
}
MyConn2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}