1

I'm need to insert an image into a filemaker container with an insert statement, and while the odbc documentation seems vague without clear examples, I'm trying to get it to work on a simple level as follows:

command line as appears in text visualizer for sqlstr:

INSERT INTO Answer ("UserID","RECNO","RECTYPE","RECSEQ",PutAs(NCICImage, 'JPEG'))
VALUES('hcd','0','0','1',?)

Here's my function to write record:

static void C2Search_WriteRecord(string sqlstr, Image img = null)
{
    OdbcCommand cmd = new OdbcCommand(sqlstr);
    if (img != null)
    {
        cmd.Parameters.AddWithValue("?", OdbcType.Image).Value = img;
    }
    cmd.Connection = connData;
    try
    {
        cmd.ExecuteNonQuery();
    }
     catch (Exception ex)
    {
        logWriteLine(DateTime.Now.ToString() + ": " + ex.Message);
    }
}

When I execute my program using the above sql statement, I get the following message which I'm confused about:

No mapping exists from object type System.Drawing.Bitmap to a known managed provider native type.

How do I make this work as desired?

4

1 回答 1

0

尝试重写SQL语句(我假设NCICImage是目标字段):

INSERT INTO Answer ("UserID","RECNO","RECTYPE","RECSEQ", "NCICImage")
VALUES('hcd', '0', '0', '1', PutAs(?, 'JPEG'))

然后绑定图像并确保它是真正的 JPEG 字节流。

于 2013-09-26T19:30:13.847 回答