データセットと完全な SQL クエリの使用の違いは何ですか?
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + System.Environment.CurrentDirectory + "\\db.accdb");
string cmd = "SELECT * FROM my_table";
conn.Open();
DataSet dset = new DataSet();
OleDbDataAdapter dadapter = new OleDbDataAdapter(cmd, conn);
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(dadapter);
dadapter.Fill(dset, "my_table");
DataTable table = dset.Tables["my_table"];
foreach (DataRow dr in table.Rows)
if ((int)dr["id"] == 123)
return true;
return false;
の間に
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + System.Environment.CurrentDirectory + "\\db.accdb");
string cmd = "SELECT 1 FROM my_table WHERE id = 123";
conn.Open();
OleDbCommand command_reader = new OleDbCommand(cmd, conn);
return command_reader.ExecuteScalar() != null;
また、特定のクエリで使用するのにデータセットの方が適していますか?