小编use*_*873的帖子

在sql server中保存字节数组

要寻找拯救,需要使用字节数组密码在此使用的方法

那么我应该在sql server中使用哪种数据类型来保存字节数组?以及如何使用SqlCommand传递和检索字节数组?

sql-server sqlcommand bytearray

20
推荐指数
2
解决办法
5万
查看次数

带有using关键字的SqlDataAdapter

这是以下代码健康吗?或者我不需要使用using关键字作为SqlDataAdapter将处理关闭连接?

public static DataSet Fetch(string sp, SqlParameter [] prm)
{
    using (SqlConnection con = new SqlConnection(ConStr))
    {
        using (SqlCommand cmd = con.CreateCommand())
        {
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = sp;
            cmd.Parameters.AddRange(prm);

            using (SqlDataAdapter dta = new SqlDataAdapter(cmd))
            {
                DataSet dst = new DataSet();
                dta.Fill(dst);

                return dst;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

@MarkGravell我在这里需要一个建议,我真的很想使用DataReader,但我一直在寻找使用该using关键字以确保关闭连接.在哪里DataReader我们不能使用它,因为如果我们想要返回DataReader某个方法,它将关闭连接.所以你认为以下技术DataReaderusing关键字一样好:

public static SqlDataReader Fetch(string sp, SqlParameter [] prm)
{
    SqlCommand cmd = new SqlConnection(ConStr).CreateCommand(); …
Run Code Online (Sandbox Code Playgroud)

c# ado.net dispose using sqldataadapter

4
推荐指数
1
解决办法
4604
查看次数