Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
program for inserting a word file content in sql server 2005 database
Posted
Comments
RDBurmon 25-Jan-13 5:14am    
Hello jalbaji ,
As this member suggested answer for your question which is correct . Please accept his solution, vote it and mark your question as 'SOLVED'

1 solution

Try:
C#
byte[] data = File.ReadAllBytes(pathToFile);
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (myColumn) VALUES (@C1)", con))
        {
        com.Parameters.AddWithValue("@C1", data);
        com.ExecuteNonQuery();
        }
    }
 
Share this answer
 
Comments
RDBurmon 25-Jan-13 5:13am    
Good 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