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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:47:05+00:00 2026-06-14T06:47:05+00:00

i have used below structure for my table in database. i can not upload

  • 0

i have used below structure for my table in database. i can not upload files more than of 1mb in the database, please help what is the problem.

fileid(int), FileName(varchar(100)), ContentType (varchar(75)), data varbinary(MAX)

protected void btnUpload_Click(object sender, EventArgs e)
{

    // Read the file and convert it to Byte Array

    string filePath = FileUpload1.PostedFile.FileName;

    string filename = Path.GetFileName(filePath);

    string ext = Path.GetExtension(filename);

    string contenttype = String.Empty;



    //Set the contenttype based on File Extension

    switch (ext)
    {

        case ".doc":

            contenttype = "application/vnd.ms-word";

            break;

        case ".docx":

            contenttype = "application/vnd.ms-word";

            break;

        case ".xls":

            contenttype = "application/vnd.ms-excel";

            break;

        case ".xlsx":

            contenttype = "application/vnd.ms-excel";

            break;

        case ".jpg":

            contenttype = "image/jpg";

            break;

        case ".png":

            contenttype = "image/png";

            break;

        case ".gif":

            contenttype = "image/gif";

            break;

        case ".pdf":

            contenttype = "application/pdf";

            break;

    }

    if (contenttype != String.Empty)
    {



        Stream fs = FileUpload1.PostedFile.InputStream;

        BinaryReader br = new BinaryReader(fs);

        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
        //insert the file into database

        Transmittallistfortest transmittalList = (Transmittallistfortest)DetailsView1.FindControl("Transmittallistfortest1");
        GridView g3 = transmittalList.FindControl("GridViewTtransmittals") as GridView;
        foreach (GridViewRow di in g3.Rows)
        {

            if (di.RowType == DataControlRowType.DataRow)
            {

                RadioButton rad = di.FindControl("RadioButton1") as RadioButton;
                //Giving Error:Object reference not set to an instance of an object.
                rad.CheckedChanged += new EventHandler(MyCheckedChangeEventHandler);
                if (rad != null && rad.Checked)
                {
                    var w = di.RowIndex;

                    string s = ((HyperLink)di.Cells[1].Controls[0]).Text;

                    var tr = from transmittal in _DataContext.tbltransmittalNos
                             where transmittal.TRANSMITTAL == s
                             select transmittal.TransID;
                    int _transid = tr.SingleOrDefault();
                    // int _transid = Convert.ToInt32(tr.SingleOrDefault()); 
                    Label1.Text = _transid.ToString();
                    Label2.Text = s;
                }
            }
        }

        tblFile fn = new tblFile();

        fn.DocId = _DocID;
        fn.TransId = Convert.ToInt32(Label1.Text);
        fn.FileName = filename;
        fn.ContentType = contenttype;
        fn.Data = bytes;

        // BookAuthor bookAuthor = new BookAuthor();
        _DataContext.tblFiles.InsertOnSubmit(fn);
        _DataContext.SubmitChanges();
        //doctranscon.TransmitToConid = Convert.ToInt32(ddlTransmittaltoCon.SelectedValue);

        lblMessage.ForeColor = System.Drawing.Color.Green;

        lblMessage.Text = "File Uploaded Successfully";


        // Update display
        DisplayDocument();

    }
}
  • 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-06-14T06:47:07+00:00Added an answer on June 14, 2026 at 6:47 am

    You are not sharing your specific error but this is likely the cause. Increase the maxRequestLength size in your web.config file. The default is 4096 KB (4 MB).

    <configuration>
       <system.web>
          <httpRuntime maxRequestLength="size in kbytes"
          ...             
          />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have this database table (some sample code below) that stores the relationship
I have table structure like below: events (boxing, sparring etc) competitors (users who are
I have used below code to attach quckboook events // Subscribe to UI events...
I want to Display Google Map into my wordpress site. I have used below
I have some problem with my cfml website. I have used the below code
I have used the code below to read rfid tag values. try { if
I have used Spring OXM and JiBX in my application. below is my Spring
Little trouble in using css, in the below code, i have used odd and
I have created a procedure and used the below statement inside that . select
I get this error when I run the code below. I have normally used

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.