Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I Want to save an text file into a sql server 2005 database???
is it possible???and also possible for retriving it??
since am an beginner..pls help me...
Posted

If you are doing this in code then try:
C#
byte[] bytes = File.ReadAllBytes(@"D:\Temp\myTextFile.txt");
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (myColumn1) VALUES (@C1)", con))
        {
        com.Parameters.AddWithValue("@C1", bytes);
        com.ExecuteNonQuery();
        }
    }
 
Share this answer
 
Comments
Rajeev Jayaram 7-Feb-12 3:29am    
5!

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