将 .NET 日期时间转换为 SQLite 日期时间 [英] Convert .NET datetime to SQlite datetime

查看:42
本文介绍了将 .NET 日期时间转换为 SQLite 日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 C# 中使用日期时间进行查询,数据库:SQlite.

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 是 DateTime 类型.

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));

这篇关于将 .NET 日期时间转换为 SQLite 日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆