嗨,我是新來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;
}
}