Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在sqlite中按日期时间选择行_C#_Sqlite - Fatal编程技术网

C# 在sqlite中按日期时间选择行

C# 在sqlite中按日期时间选择行,c#,sqlite,C#,Sqlite,我试图用sqlite在c#中选择介于startdate和enddate之间的行 我的日期格式如下: 2015-05-16T17:22:04.920+02:00 string CmdString = "SELECT * FROM " + tablename + "WHERE DATETIME(timekey) >= DATETIME('2015-05-16T17:22:04.920+02:00') AND DATETIME(timekey) <= DATETIME('2015-05

我试图用sqlite在c#中选择介于startdate和enddate之间的行

我的日期格式如下:

2015-05-16T17:22:04.920+02:00
string CmdString = "SELECT * FROM " + tablename +  "WHERE DATETIME(timekey) >= DATETIME('2015-05-16T17:22:04.920+02:00') AND DATETIME(timekey) <= DATETIME('2015-05-16T17:24:04.920+02:00')";
SQLiteCommand cmd = new SQLiteCommand(CmdString, con);
SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
DataTable MatchDt = new DataTable();

sda.Fill(MatchDt);
这应该是sqlite的有效格式(参考:)

我正在尝试按如下方式选择行:

2015-05-16T17:22:04.920+02:00
string CmdString = "SELECT * FROM " + tablename +  "WHERE DATETIME(timekey) >= DATETIME('2015-05-16T17:22:04.920+02:00') AND DATETIME(timekey) <= DATETIME('2015-05-16T17:24:04.920+02:00')";
SQLiteCommand cmd = new SQLiteCommand(CmdString, con);
SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
DataTable MatchDt = new DataTable();

sda.Fill(MatchDt);

我做错了什么?

在where之前缺少一个空格字符:

string CmdString = "SELECT * FROM " + tablename +  " WHERE DATETIME(timekey) >= DATETIME('2015-05-16T17:22:04.920+02:00') AND DATETIME(timekey) <= DATETIME('2015-05-16T17:24:04.920+02:00')";

您在WHERE之前缺少一个空格。