开发者

Convert .NET datetime to SQlite datetime

开发者 https://www.devze.com 2023-01-03 21:53 出处:网络
I\'ve tried to query with a datetime in C#, database : SQlite. cmd.CommandText = @\"select * from PhieuNhap where NgayNhap=$NgayNhap\";

I've tried to query with a datetime in C#, database : SQlite.

cmd.CommandText = @"select * from PhieuNhap where NgayNhap=$NgayNhap";
cmd.Parameters.Add(new SQLiteParameter开发者_开发问答("$NgayNhap", SqlDbType.DateTime).Value = ngayNhap;

ngayNhap is a DateTime type.

But it seems doesn't work this way .


Do you get an exception or is the value just ignored?

One thing you could try is not setting the parameter type manually:

cmd.CommandText = @"select * from PhieuNhap where NgayNhap=$NgayNhap";
cmd.Parameters.Add(new SQLiteParameter("$NgayNhap", ngayNhap));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号