【发布时间】:2013-11-26 02:27:41
【问题描述】:
我有一个用 WPF 3.5 编写的应用程序,它有时会将数据保存在 SQL Server 中包含图像中,这是保存数据的代码的一部分(注意 this.pictureImage 是 WPF Image 控件) :-
using (SqlCommand command = myConnection.CreateCommand())
{
String sqlInsertCommand = "INSERT INTO Info_Id (idNumber, FirstName, Nationality, Image) VALUES (@idNumber, @firstName, @nationality, @image)";
command.CommandText = sqlInsertCommand;
command.CommandType = System.Data.CommandType.Text;
command.Parameters.AddWithValue("@idNumber", this.cardIdTextBlock.Text);
command.Parameters.AddWithValue("@firstName", this.fullNameTextBlock.Text);
command.Parameters.AddWithValue("@nationality", this.nationaltyTextBlock.Text);
command.Parameters.AddWithValue("@image", this.pictureImage);
command.ExecuteNonQuery();
}
运行此程序并单击“保存到数据库”按钮后,出现以下错误。
不存在从对象类型 System.Windows.Controls.Image 到已知托管提供程序的映射
在 SQL Server 数据库中,我有一行 (Picture (Image, null))。
请给我建议。谢谢。
【问题讨论】:
标签: sql-server wpf wpf-controls