MySqlConnection.StateChange 是如何工作的?
我有以下代码。
conn.StateChange += ConnectionStateChanged;
private void ConnectionStateChanged(Object sender, StateChangeEventArgs e) {
switch (e.CurrentState) {
// is never equal to Fetching
}
}
public DataTable Query(string query) {
DataTable dt = new DataTable();
using (MySqlDataAdapter a = new MySqlDataAdapter(query, conn)) {
try {
a.SelectCommand.CommandTimeout = 5;
a.Fill(dt);
} catch {
return null;
}
}
return dt;
}
为什么从未使用 ConnectionState.Fetching 或 ConnectionState.Executing 调用 ConnectionStateChanged?