如何在Winform中使用c#在数据转发器中绑定图像。
我将图像保存为sql服务器中的字节。现在我想检索图像并希望在winform中的转发器中显示。
SqlConnection con = new SqlConnection(connection.mando());
SqlCommand cmd = new SqlCommand(str, con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.CommandType = CommandType.Text;
da.SelectCommand = cmd;
cmd.Connection = con;
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
// Bind data to TextBox
textBox1.DataBindings.Add("Text", da, "QUESTION");
label2.DataBindings.Add("Text", da, "OPCTION1");
label3.DataBindings.Add("Text", da, "OPCTION2");
label4.DataBindings.Add("Text", da, "OPCTION3");
label5.DataBindings.Add("Text", da, "OPCTION4");
int c = ds.Tables[0].Rows.Count;
if (c == 1)
{
Byte[] MyData = new byte[0];
MyData = (Byte[])ds.Tables[0].Rows[7]["IMAGE1"];
MemoryStream stream = new MemoryStream(MyData);
stream.Position = 7;
pictureBox1.Image = Image.FromStream(stream);
}
dataRepeater1.Visible = true;
dataRepeater1.DataSource = ds.Tables[0];
在以图像形式存储在sql server中后,如何使用c#在winform中的数据转发器控件中显示图像。