//查询全表并绑定在datatable中 public static DataTable datatable(string selectStr) { con.Close(); con.Open(); MySqlCommand command = new MySqlCommand(selectStr, con); MySqlDataAdapter adapter = new MySqlDataAdapter(selectStr, Connectionsql.ConnectStr()); DataTable dataTable = new DataTable(); adapter.Fill(dataTable); con.Close(); return(dataTable); }
//查询表中新添加的数据 public static DataTable selectnew(string selectStr) { con.Close(); con.Open(); MySqlCommand command = new MySqlCommand(selectStr, con); command.ExecuteNonQuery(); DataSet dataSet = new DataSet(); MySqlDataAdapter adapter = new MySqlDataAdapter(selectStr, Connectionsql.ConnectStr()); adapter.SelectCommand = command; adapter.Fill(dataSet); DataTable data = dataSet.Tables[0]; con.Close(); return(data); }