For storing the file, you can use varbinary(max) type in sql table. Then first you read file into a memory stream:
FileStream st = new FileStream(@"C:\pdfname.pdf", FileMode.Open);
byte[] buffer = new byte[st.Length];
st.Read(buffer, 0, (int)st.Length);
st.Close();
then put that stream into byte array, and then insert the byte array to sql:
SqlConnection conn = new SqlConnection("...");
SqlCommand cmd = new SqlCommand("UPDATE SomeTable SET pdf=@pdf WHERE ID = 1", conn);
cmd.Parameters.AddWithValue("@pdf", buffer);
conn.Open();
int i = cmd.ExecuteNonQuery();
conn.Close();
If you want to "remember" the file names, you should open up another column in the table for storing file names. For retrieving files, just do the reverse:
SqlConnection connection = new SqlConnection ("...");
connection.Open ();
SqlCommand command = new
SqlCommand ("select pdf from Table", connection);
byte[] buffer = (byte[]) command.ExecuteScalar ();
connection.Close();
FileStream fs = new FileStream(@"C:\test.pdf", FileMode.Create);
fs.Write(buffer, 0, buffer.Length);
fs.Close();
If your file is too big to handle with integers, you should implement buffer mechanism;i.e. save bytes in manageable portions.
Examples for this and further information can be found
here