C# 查询Access数据库
我要查询上表大于Mindim小于Maxdim如何写查询语句???我这样写的stringsql="selectIT9fromdimwhereMaxdim>='"+this....
我要查询上表大于Mindim 小于Maxdim如何写查询语句???
我这样写的
string sql = "select IT9 from dim where Maxdim>= '" + this.textBox1.Text + "'and Mindim<'" + this.textBox1.Text + "' ";
报错类型不匹配,如何修改??? 展开
我这样写的
string sql = "select IT9 from dim where Maxdim>= '" + this.textBox1.Text + "'and Mindim<'" + this.textBox1.Text + "' ";
报错类型不匹配,如何修改??? 展开
1个回答
2014-05-22
展开全部
String sql = "select IT9 from [dim] where Maxdin >= " + this.textBox1.Text + " and Mindim < " + this.textBox1.Text;
追问
OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataReader reader = cmd.ExecuteReader();
至少一个参数没有被指定值。
追答
public static DataSet LoadDataFromAccess(string DataFileName, string Sql)
{
try
{
string strConn = "Provider=microsoft.ace.oledb.12.0;Data Source=" + DataFileName;
//string strConn = "Provider=microsoft.oledb.jet.4.0;Data Source=" + DataFileName;
OleDbConnection Conn = new OleDbConnection(strConn);
OleDbCommand cmd = new OleDbCommand(Sql, Conn);
OleDbDataAdapter oda = new OleDbDataAdapter();
oda.SelectCommand = cmd;
DataSet ds = new DataSet();
oda.Fill(ds);
return ds;
}
catch
{
return null;
}
}
String sql = "select IT9 from [dim] where Maxdim >= " + this.textBox1.Text + " and Mindim < " + this.textBox1.Text;
字段名别拼错啦,我老是把m按成n
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询