如何检索文件并保存文本区域中包含的内容... [英] How I Can Retrieve A File And Save It's Contain In Text Area...

查看:53
本文介绍了如何检索文件并保存文本区域中包含的内容...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



你好...



我想从sql server检索文件并将其包含在文本区域中。 。



请帮帮我...

解决方案

< blockquote>尝试:

 使用(SqlConnection con =  new  SqlConnection(strConnect))
{
con.Open();
使用(SqlCommand cmd = new SqlCommand( SELECT fileContent FROM myTable WHERE ID = @ ID,con))
{
cmd.Parameters.AddWithValue( @ ID,idOfFileInTable);
使用(SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
int id =( int )reader [ iD];
string content =( string )reader [ fileContent];
myTextBox.Text = content;
}
}
}
}



hello...

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

Please help me...

解决方案

Try:

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;
                }
            }
        }
    }


这篇关于如何检索文件并保存文本区域中包含的内容...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆