Tzu ng
Tzu ng

Reputation: 9244

Convert .NET datetime to SQlite datetime

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 .

Upvotes: 1

Views: 2173

Answers (1)

Jürgen Steinblock
Jürgen Steinblock

Reputation: 31723

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

Upvotes: 2

Related Questions