hox6

导航

 

 

//添加----------------------------------------------------------------------------------------------
string sqlinsert = "INSERT INTO bookshop(编号,书名,价格) VALUES (@编号,@书名,@价格)";


using (MySqlCommand command = new MySqlCommand(sqlinsert, connection))
{
command.Parameters.AddWithValue("@编号", 7 );
command.Parameters.AddWithValue("@书名", "检测管理");
command.Parameters.AddWithValue("@价格", 14.5);

int rowsAffected = command.ExecuteNonQuery();

if (rowsAffected > 0)
{
Console.WriteLine("\n" + "\n" + "数据插入成功!");
}
else
{
Console.WriteLine("数据插入失败!");
}
}

posted on 2023-08-22 09:24  云杉木板  阅读(68)  评论(0编辑  收藏  举报