1. Question: i like to save this image background(see on photo inserted) in my database if there is no upload photo in picture box. how i can do that? the because i am getting this catch message
Object reference not set to an instance of an object
//Converting Image
public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
// Inserting Image to database
cmd.Parameters.Add("@Image", SqlDbType.VarChar).Value = Convert.ToString(ImageToBase64(pbPicture.Image, System.Drawing.Imaging.ImageFormat.Jpeg));