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 6104897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:53:42+00:00 2026-05-23T13:53:42+00:00

I am trying to save image from fileupload control into the database public Byte[]

  • 0

I am trying to save image from fileupload control into the database

public Byte[] bytes;
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
bytes = br.ReadBytes((Int32)fs.Length);
SqlDataSource2.Update();

protected void SqlDataSource2_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
   e.Command.Parameters["@project_file"].Value = bytes;
}

My database project_file field is set to varbinary(MAX),

but it is throwing an error

Parameter ‘@project_file’ exceeds the size limit for the sql_variant datatype.

Please suggest some solution

  • 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-23T13:53:42+00:00Added an answer on May 23, 2026 at 1:53 pm

    This is a quote from MSDN on binary and varbinary:

    Variable-length binary data. n can be
    a value from 1 through 8,000. max
    indicates that the maximum storage
    size is 2^31-1 bytes. The storage size
    is the actual length of the data
    entered + 2 bytes. The data that is
    entered can be 0 bytes in length. The
    ANSI SQL synonym for varbinary is
    binary varying.

    varbinary(MAX) can hold an image that is ~2GB of size.

    Solution to your problem:

    You forgot to specify the type in your code. You need to set the correct SqlDbType.

    e.Command.Parameters["@project_file"].SqlDbType = SqlDbType.VarBinary

    What you should also do i set the correct Size.

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

Sidebar

Related Questions

I'm trying to save a file (pdf or image) uploaded from a form into
I am trying to take a Base64 encoded image from the database and save
I have a FileUpload control. I am trying to save the file that is
I am trying to save image captured from web cam with current time.Like 06.06.2010
I'm trying to save a copied image from the clipboard but it's losing its
I am trying to save a JPEG image from a URL to a file
I am trying to save out a large image from flash using bitmapdata and
I'm trying to store three images from a form (PictureBox's) into a SQL Database
Im just trying to save a file to disk using a posted stream from
I am trying to save data to a database on a button push, but

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.