private void b5_Click(object sender, EventArgs e)
{
string txt5 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\c#\\st1.mdb";
Conn = new OleDbConnection(txt5);
Conn.Open();
string txt6 = "SELECt * FROM ff1 WHERe";
txt6 += comboBox1.Text + "LIKE'";
txt6+=t5.Text+"'";
dad1 = new OleDbDataAdapter(txt6,txt5);
ds = new DataSet("ds");
dad1.Fill(ds, "ff1");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "ff1";
}
C#问题 FROM 子句语法错误
答案:1 悬赏:40 手机版
解决时间 2021-01-25 15:36
- 提问者网友:謫仙
- 2021-01-24 14:54
最佳答案
- 五星知识达人网友:平生事
- 2021-01-24 16:07
这样的问题,你自己设个断点调试一下即可。因为你的代码极具限制性,我没法帮你调试。首先你的where 后面如果有条件记得价格空格,这个你没有。第二不知道comboBox1.Text 是不是数据库字段名,如果是那后面和like也要加空格。再者like 和后面的也要加空格。我在你的代码基础上做了调整,你看一下,为了显示明显,我加多个空格了。
private void b5_Click(object sender, EventArgs e)
{
string txt5 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\c#\\st1.mdb";
Conn = new OleDbConnection(txt5);
Conn.Open();
string txt6 = "SELECt * FROM ff1 WHERe ";
txt6 += comboBox1.Text + " LIKE '";
txt6+=t5.Text+"'";
dad1 = new OleDbDataAdapter(txt6,txt5);
ds = new DataSet("ds");
dad1.Fill(ds, "ff1");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "ff1";
}
private void b5_Click(object sender, EventArgs e)
{
string txt5 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\c#\\st1.mdb";
Conn = new OleDbConnection(txt5);
Conn.Open();
string txt6 = "SELECt * FROM ff1 WHERe ";
txt6 += comboBox1.Text + " LIKE '";
txt6+=t5.Text+"'";
dad1 = new OleDbDataAdapter(txt6,txt5);
ds = new DataSet("ds");
dad1.Fill(ds, "ff1");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "ff1";
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯