"select * from '" + textBox1.Text.Trim()+"' where '"+DBFName +"'//'" + textBox1.Text.Trim()+"'这些表名或字段名根本就不用''号,你用了''号就错了
如果TextBox1是表名,其他TextBox是字段名的话 "select * from '" + textBox1.Text.Trim()+"' where DBFName='"+ExcelName +"'and BFCode='" +ExcelCode +"' and DBFKsh ='"+ExcelKsh +"' and DBFXxmc ='" + Xxmc + "'";
是C#CODE,再发一下 "select * from '" + textBox1.Text.Trim()+"' where DBFName='"+ExcelName +"' and BFCode='" +ExcelCode +"' and DBFKsh ='"+ExcelKsh +"' and DBFXxmc ='" + Xxmc + "'";
试试,看有行不?有的话是你where条件不对。
where 变量1=变量2
如何写?
谢谢!
你的DBFName ,DBFCode,DBFKsh ,DBFXxmc 的值是怎么获得的?
这里直接写数据库的字段名就可以了。
string DBFName=textBox4 .Text .Trim ();
string DBFCode=textBox5 .Text .Trim ();
string DBFKsh=textBox6 .Text .Trim ();
string DBFXxmc=textBox9 .Text .Trim ();
如果你要比较两个变量,就应该在查询前设置条件
if(DBFName == ExcelName && DBFCode == ExcelCode &&...)
{}
"select * from '" + textBox1.Text.Trim()+"' where DBFName='"+ExcelName +"'and BFCode='" +ExcelCode +"' and DBFKsh ='"+ExcelKsh +"' and DBFXxmc ='" + Xxmc + "'";
"select * from '" + textBox1.Text.Trim()+"' where DBFName='"+ExcelName +"' and BFCode='" +ExcelCode +"' and DBFKsh ='"+ExcelKsh +"' and DBFXxmc ='" + Xxmc + "'";