各位大侠,帮咱看个问题,看哪出问题了。急求解,谢谢
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行数据
不过,执行查询全部数据时挺正常的。郁闷中……
代码分在几个文件中,只放几个必要的,需要的话,回帖再贴
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行数据
不过,执行查询全部数据时挺正常的。郁闷中……
代码分在几个文件中,只放几个必要的,需要的话,回帖再贴
{
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, TableName);
command.Fill(ds);
dt = ds.Tables[0];
}
catch (System.Data.SQLite.SQLiteException ex)
{
throw new Exception(ex.Message);
}
return dt;
}
}
函数是这样儿的
这里的单引号 你的好像是中文式的 改成英文式的看看呢?