こんにちは、Azure ストレージ BLOB は初めてです。私は WPF にプロジェクトを持っており、ボタンのクリックで画像を送信/アップロードできるコンテナーを azure ストレージ BLOB に作成しました。私のWPFプロジェクトで画像にアクセス/使用/表示できるようにする文字列フォームをBLOBからSQLデータベースに保存できるかどうか、誰か教えてください。
誰かが私に例を教えてくれるかもしれません! ありがとう!
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;
}
}