我正在尝试从Access数据库的两个不同表中获取匹配值。我想知道是否有可能从单元格以“SN”开头的列中获取值,并将所有其余数据保留。这是我到目前为止所拥有的。
String filePath = textBox1.Text;
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* FROM [AC_ECONOMIC] Where KEYWORD = '" + end + "'AND QUALIFIER = '" + qual + "' AND EXPRESSION = '", con); // ISSUE AFTER EXPRESSION=
ds.Clear();
ad.Fill(ds);
con.Open();
ad.SelectCommand.ExecuteNonQuery();
con.Close();
ad3.SelectCommand = new OleDbCommand("SELECT* FROM [AC_ECONOMIC] Where KEYWORD = '" + start + "'AND QUALIFIER = '" + qual + "'", 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();
}
我想我只是想在EXPRESSION区域之后添加一些代码,但我不太清楚从哪里开始。我只是想让它读起来像AND EXPRESSION = startswith(“SN”)。任何帮助将不胜感激。