我試圖插入一個圖片(.bmp)到Filemaker的容器字段。我設法讓它插入正常,但它將其保存爲.dat文件。我想知道是否有一種方法來指定將其保存爲什麼文件類型?插入圖像文件到Filemaker容器使用C#
try
{
Bitmap tempImage = new Bitmap("C:\\temp\\black.bmp");
System.IO.MemoryStream stream = new System.IO.MemoryStream();
tempImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] image = stream.ToArray();
OdbcConnection connection = new OdbcConnection("DSN=Filemaker;UID=admin");
connection.Open();
OdbcCommand command = new OdbcCommand("INSERT INTO TestDatabase (LocatorNum, FileName, SampleSet, Image) VALUES (" +
"'003'" + ", " +
"'003'" + ", " +
"'003'" + ", " +
"?" + ")");
command.Connection = connection;
command.Parameters.AddWithValue("?", OdbcType.VarBinary).Value = image;
command.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
我也忘了提及它保存爲「Untitled.dat」,所以我也需要指定文件名。謝謝。 – user2009352 2013-03-21 21:01:25