Click here to Skip to main content
15,746,420 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to store my resume data into the resume_data column defined as image type of sql table on the addbutton_click event in windows not in web.
Updated 14-Oct-12 23:40pm
Vinod Satapara 15-Oct-12 9:09am    
Please provide more details. Do you want to save .doc or .docx file in sql table image type of column?
StackQ 16-Oct-12 7:51am    
both type,input file may be in (.doc or .docx)

private byte[] ResumeData;
public byte[] ResumeData_
    get { return ResumeData; }
    set { ResumeData = value; }

string Connstr=System.Configuration.ConfigurationManager.AppSettings["Connstr"].ToString();

public void Submit()

    SqlCommand Cmd = new SqlCommand();
    SqlConnection Conn = new SqlConnection(Connstr);
    Cmd.Connection = Conn;
    Cmd.CommandType = CommandType.StoredProcedure;
    Cmd.CommandText = "SP_Insert_Joinee";

    Para1 = new SqlParameter();
    Para1.ParameterName = "@ResumeData";
    Para1.SqlDbType = SqlDbType.Image;
    Para1.Value = ResumeData;

public Document FileToByteArray(string fileName)
           byte[] fileContent = null;

           System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
           System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fs);
           long byteLength = new System.IO.FileInfo(fileName).Length;
           fileContent = binaryReader.ReadBytes((Int32)byteLength);
           Document objDoc = new Document();
           objDoc.DocName = fileName;
           objDoc.DocContent = fileContent;
           return objDoc;
      public class Document
       public int DocId { get; set; }
       public string DocName { get; set; }
       public byte[] DocContent { get; set; }

private void btnSubmit_Click(object sender, EventArgs e)
              //many statements

              Document objDoc = new Document();
              objDoc.DocContent = Attachmnt;//attachment defined as byte[] Attachment;
              objEntity.ResumeData_ = objDoc.DocContent;
              MessageBox.Show("Records Added Successfully!");

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900