我有两个数据集,我正在从 Access 数据库中读取两个表。我希望能够通过 EXPRESSION 匹配数据,以便保留所有匹配的“SN”并摆脱那些没有匹配的数据。到目前为止,我的代码保留了所有的“SN”。这里是,
con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+filePath);
con3 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+filePath);
if ((string)comboBox1.SelectedItem == "CGA0112")
{
try
{
string end = "ENDDATE";
string qual = "CGA0112";
string start = "START";
ad.SelectCommand = new OleDbCommand("SELECT b.RSV_CAT, b.SEQNUM, b.LEASE,
b.WELL_ID, a.QUALIFIER, a.KEYWORD, a.EXPRESSION
FROM [AC_ECONOMIC] a INNER JOIN [AC_PROPERTY] b
on a.PROPNUM=b.PROPNUM WHERE a.KEYWORD = '" +end+ "'
AND a.QUALIFIER = '" +qual+ "' AND a.EXPRESSION LIKE 'SN%'", con);
ds.Clear();
ad.Fill(ds);
con.Open();
ad.SelectCommand.ExecuteNonQuery();
con.Close();
ad3.SelectCommand = new OleDbCommand("SELECT b.RSV_CAT, b.SEQNUM, b.LEASE,
b.WELL_ID, a.QUALIFIER, a.KEYWORD, a.EXPRESSION
FROM [AC_ECONOMIC] a INNER JOIN [AC_PROPERTY] b
on a.PROPNUM=b.PROPNUM
WHERE a.KEYWORD = '" + start + "' AND a.QUALIFIER = '" +
qual + "' AND a.EXPRESSION LIKE 'SN%'", con3);
ds3.Clear();
ad3.Fill(ds3);
ds.Merge(ds3); //merges the two datasets together
win1.frm1 = this;
win1.Show();
con3.Open();
ad3.SelectCommand.ExecuteNonQuery();
con3.Close();
}
我想知道是否有可能的解决方案,所以它只保留匹配的表达式。任何帮助深表感谢。谢谢。