Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 501781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:13:29+00:00 2026-05-13T06:13:29+00:00

hi thanks a lot i have one code below in this code ill upload

  • 0

hi thanks a lot i have one code below in this code ill upload one image . convert it into
byte code and store it in database .. and retrive it in gridview .. the thing is before
converting it into byte code i want to resize it could u plz tell me what code i should insert here … thanks a lot .. …

protected void btnUpload_Click(object sender, EventArgs e)
{
 string strID= txtid.Text.ToString();
 string strImageName = txtName.Text.ToString();
 if (FileUpload1.PostedFile != null && 
     FileUpload1.PostedFile.FileName != "")
  {


   byte[] imageSize = new byte
                 [FileUpload1.PostedFile.ContentLength];

  HttpPostedFile uploadedImage = FileUpload1.PostedFile;
  uploadedImage.InputStream.Read
     (imageSize, 0, (int)FileUpload1.PostedFile.ContentLength);

 // Create SQL Connection 
  SqlConnection con = new SqlConnection("user id=sa;password=Zoomin@123;database=salary_db;server=192.168.1.100");


 // Create SQL Command 

 SqlCommand cmd = new SqlCommand();
 cmd.CommandText = "INSERT INTO image1(ID,ImageName,Image)" +
                   " VALUES (@ID,@ImageName,@Image)";
 cmd.CommandType = CommandType.Text;
 cmd.Connection = con;


 SqlParameter ID = new SqlParameter
                   ("@ID", SqlDbType.VarChar, 50);
 ID.Value = strID.ToString();
 cmd.Parameters.Add(ID);

 SqlParameter ImageName = new SqlParameter
                     ("@ImageName", SqlDbType.VarChar, 50);
 ImageName.Value = strImageName.ToString();
 cmd.Parameters.Add(ImageName);

 SqlParameter UploadedImage = new SqlParameter
               ("@Image", SqlDbType.Image, imageSize.Length);
 UploadedImage.Value = imageSize;
 cmd.Parameters.Add(UploadedImage);
 con.Open();
 int result = cmd.ExecuteNonQuery();
 con.Close();
 if (result > 0)
 lblMessage.Text = "File Uploaded";

 GridView1.DataBind();

 }}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:13:30+00:00Added an answer on May 13, 2026 at 6:13 am

    You could use the following function:

    public void ResizeImage(double scaleFactor, Stream fromStream, Stream toStream)
    {
        using (var image = Image.FromStream(fromStream))
        {
            var newWidth = (int)(image.Width * scaleFactor);
            var newHeight = (int)(image.Height * scaleFactor);
            using (var thumbnailBitmap = new Bitmap(newWidth, newHeight))
            using (var thumbnailGraph = Graphics.FromImage(thumbnailBitmap))
            {
                thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
                thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
                thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
                var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
                thumbnailGraph.DrawImage(image, imageRectangle);
                thumbnailBitmap.Save(toStream, image.RawFormat);
            }
        }
    }
    

    The name of the parameters should be pretty self-explanatory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Theora is an excellent open source codec with very good… May 16, 2026 at 10:56 am
  • Editorial Team
    Editorial Team added an answer This is a direct answer to the question, except for… May 16, 2026 at 10:56 am
  • Editorial Team
    Editorial Team added an answer A bit decent web application consists of a mix of… May 16, 2026 at 10:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have been doing a lot of searching and still can't seem to figure
I'm working with a system which had to create objects in one database based
I have tried a lot to learn linked list.But all my efforts were wasted.Please
I have a PHP program that reads from the database and generated formatted sheets.
Let's say that I have a form which runs a stored procedure. This stored
If one of relational databases paradigms is to be tuple oriented we have the
Hi: jQuery spoiled me a lot ;-) I am one of the early adapters
I have been studying the modalforms & inline formsets but am not able to
My problem is in regards file copying performance. We have a media management system
I have a bunch of 'rowviews' that I want to put in a vertical

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.