使用Dapper写入MS Access时的OleDbException

时间:2015-06-26 10:58:40

标签: ms-access f# oledb dapper

我尝试使用Dapper插入到我的MS Access数据库中,现在查询数据工作正常,但是当我尝试插入时,我得到System.Data.OleDb.OleDbException : Data type mismatch in criteria expression

代码是:

let conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=path;Persist Security Info=False;")

let exec f =
    try
        conn.Open()
        do f() 
    finally
        conn.Close()

[<CLIMutable>]
type Timecard =
    { Id          : int
      Employee    : string
      WorkDate    : DateTime
      Hours       : int
      Description : string
      BillType    : string }

exec (fun () -> 
        let tc = { Id = 0
                   Employee = "John Doe" 
                   WorkDate = DateTime.Today 
                   Hours = 10
                   Description = "working 9 to 5"
                   BillType = "BillableInternal" }
        conn.Execute("insert into Timecards (Employee, WorkDate, Hours, Description, BillType) values (@Employee, @WorkDate, @Hours, @Description, @BillType)", tc)             
       |> ignore)

0 个答案:

没有答案