我正在尝试在 while 循环中使用数据适配器更新我的 sql 数据库。第一个循环很好,但是当我更新数据库然后在第二个循环中,选择查询的行是空白的。适配器是否锁定数据库?
while (true)
{
using (MySqlConnection dbConnection = new MySqlConnection(connectionString))
{
using (MySqlCommand selectCommand = dbConnection.CreateCommand())
{
selectCommand.CommandText = "Select * from Status";
using (MySqlDataAdapter adapter = new MySqlDataAdapter(selectCommand))
{
using (MySqlCommandBuilder builder = new MySqlCommandBuilder(adapter))
{
using (DataTable table = new DataTable())
{
adapter.Fill(table);
table.Rows[0][1] = "data-" + count.ToString();
adapter.Update(table);
}
}
}
}
}
System.Threading.Thread.Sleep(1000);
}