嗨,我是新来azure存储blob。我在WPF中有一个项目,并且我已经在Azure存储区创建了一个容器,我可以在单击按钮时发送/上传图像。任何人都可以告诉我,如果我可以将blob字符串存储到我的sql数据库中,这将允许我在我的WPF项目中访问/使用/显示图像。在数据库表中存储一个斑点字符串
也许有人可以指导我举一个例子!谢谢!
private void btnSAVE_Click(object sender, RoutedEventArgs e)
{
try
{
byte[] photo = GetPhoto(filePath);
sc.Open();
cmd = new SqlCommand("Insert into Rewards (Name, Picture, ) values'" + txtName.Text+ "','" + txtPicture.Text + "')", sc);
cmd.Parameters.Add("@Picture", SqlDbType.Image, photo.Length).Value = photo;
cmd.ExecuteNonQuery();
MessageBox.Show("Inserted");
sc.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
displayAll();
}
private byte[] GetPhoto(string filePath) {
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] photo = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
return photo;
}
}