日期:2014-05-18  浏览次数:20803 次

sqlite+c# 带数据库函数时查询不出数据,急求答案中……
各位大侠,帮咱看个问题,看哪出问题了。急求解,谢谢
  public DataTable GetLicsByYM(string str,string value) {
  SQLiteHelper dbc = new SQLiteHelper();
  string sql = "select * from tb_License where " + str + "='" + value.Trim() + "'";
  DataTable dt = dbc.Query(sql, "table");
  return dt;
  }
这是SQLiteHelper里边函数
  public DataTable Query(string SQLString, string TableName)
  {
  using (SQLiteConnection connection = new SQLiteConnection(connectionString))
  {
  DataSet ds = new DataSet();
  DataTable dt = new DataTable();
  try
  {
  connection.Open();
  SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
  command.Fill(ds);
  dt = ds.Tables[0];
  }
  catch (System.Data.SQLite.SQLiteException ex)
  {
  throw new Exception(ex.Message);
  }
  return dt;
  }
  }
这儿是调用。
DataTable dt=GetLicsByYM("substr(date,0,8)", t_txtNum.ToString().Trim());
问题就是执行带函数据sql语句时查不出数据来。总是0行数据
不过,执行查询全部数据时挺正常的。郁闷中……
代码分在几个文件中,只放几个必要的,需要的话,回帖再贴

------解决方案--------------------
DataTable dt = dbc.Query(sql, "table");

這個"table"是啥?連接字符串?
------解决方案--------------------
table 應該使用實際的表名吧
------解决方案--------------------
str + "= ' " + value.Trim() + " ' ";
这里的单引号 你的好像是中文式的 改成英文式的看看呢?

------解决方案--------------------
我认识楼主,我在帮她顶贴
------解决方案--------------------
大家一起来顶呀,一起来顶死她!!!!!!!!