我正在尝试针对 Sqlite 数据库实现数据访问层。我的一张表包含一个日期时间字段。
我在将数据插入此日期时间字段时遇到问题。
cmd.CommandText = string.Format(
"INSERT INTO Orders(" +
"OrderId, " +
"Status, " +
"CreationTime, " +
"LastModification, " +
"CreatorName) " +
"VALUES(@orderId,@status,@creation,@modification,@creator)";
cmd.Parameters.AddWithValue("@orderId", orderId);
cmd.Parameters.AddWithValue("@status", status);
cmd.Parameters.AddWithValue("@creation", creationTime);
cmd.Parameters.AddWithValue("@modification", lastModificationTime);
cmd.Parameters.AddWithValue("@creator", creatorName);
我的表创建:
cmd.CommandText = "CREATE TABLE IF NOT EXISTS Orders(" +
"OrderId TEXT PRIMARY KEY NOT NULL, " +
"Status TEXT, " +
"CreationTime DATETIME, " +
"LastModification DATETIME, " +
"CreatorName TEXT)";