Hi sourabh,
Try below code to read file bytes and save in database.
try
{
byte[] bytes = System.IO.File.ReadAllBytes(Server.MapPath("FileName"));
Utility ut = new Utility();
SqlConnection con = new SqlConnection(ut.conStr);
SqlCommand command = new SqlCommand("Insert into TableName([Size], [Doc]) Values(@FSize, @FContent)", con);
command.CommandType = CommandType.Text;
command.Parameters.AddWithValue("@FSize", bytes.Length);
command.Parameters.AddWithValue("@FContent", bytes);
con.Open();
command.ExecuteNonQuery();
con.Close();
}
catch (System.Exception exc)
{
Response.Write("Problem occur! " + exc.Message);
}
Regards,
sourabhghosh49-13964, if this helps please login to Mark As Answer. | Alert Moderator