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);
Conn.Open();
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;
Cmd.Parameters.Add(Para1);
Cmd.ExecuteNonQuery();
}
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);
fs.Close();
fs.Dispose();
binaryReader.Close();
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)
{
Document objDoc = new Document();
objDoc.DocContent = Attachmnt;
objEntity.ResumeData_ = objDoc.DocContent;
objEntity.Submit();
MessageBox.Show("Records Added Successfully!");
this.Close();
}