Hi guys, I am trying to insert image into the database ... I tried everything to do so ...
But still it displaying the error like:

Cannot implicitly convert type 'System.Drawing.Image' to 'System.Web.UI.WebControls.Image'

The code is like this:

public partial class Image : System.Web.UI.Page
{
    tblImage objImage = new tblImage();

    private byte[] ConvertImageToByteArray(System.Drawing.Image imageToConvert,
    System.Drawing.Imaging.ImageFormat formatOfImage)

    {
        byte[] Ret;
        try
        {
            using (MemoryStream ms = new MemoryStream())
            {
                imageToConvert.Save(ms, formatOfImage);
                Ret = ms.ToArray();
            }
        }
        catch (Exception) { throw; }
        return Ret;
    }

    protected void btnUpload_Click(object sender, EventArgs e)
    {
        objImage.ImageName = txtName.Text;

        if (FileUploadControl.HasFile)
        {
            try
            {

         
    System.Drawing.Image imag = System.Drawing.Image.FromStream
                        (FileUploadControl.PostedFile.InputStream);

    objImage.Image = (imag);     // Here It is showing the error like "Cannot implicitly convert type 'System.Drawing.Image'
                                // to 'System.Web.UI.WebControls.Image'.. How to convert it???


            }
            catch (Exception ex)
            {
                Label1.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
            }

        }

        objImage.InsertNewUser();
        Label1.Text = "Record Successfully inserted into the database";
    }

Guys plz suggest how to rectify this error???

How to compare Method objImage.Image(System.Web.UI.WebControls.Image) with imag(System.Drawing.Image)... 'imag' is the picture which i am uploading using fileupload control...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.