I know there is a way to upload images to the database as image type or varbinary type, however, I searched around the entire week, I am unable to find anything that can hel
If you're okay storing the image as a VARCHAR, here is some code to do so.
String b64;
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
this.pic.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Byte[] bytes = ms.ToArray();
b64 = Convert.ToBase64String(bytes);
}
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("UPDATE [settings] SET [value] = @val WHERE [id] = 2", conn))
{
conn.Open();
cmd.Parameters.Add(new SqlParameter("@val", b64));
cmd.ExecuteNonQuery();
conn.Close();
}
}