Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

hello...

I want to retrieve file from sql server and put it's contain into text area..

Please help me...
Posted
Comments
Karthik_Mahalingam 29-Jan-14 4:05am    
File from SQL or web server ??

1 solution

Try:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("SELECT fileContent FROM myTable WHERE ID=@ID", con))
        {
        cmd.Parameters.AddWithValue("@ID", idOfFileInTable);
        using (SqlDataReader reader = cmd.ExecuteReader())
            {
            if (reader.Read())
                {
                int id = (int) reader["iD"];
                string content = (string) reader["fileContent"];
                myTextBox.Text = content;
                }
            }
        }
    }
 
Share this answer
 
v2

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