0

我希望在 CLR 存储过程中使用 Cryptography API。

我创建了一个 CLR 存储过程并编写了一个 select 语句

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Context Connection=true";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = @"select * from Employee";

SqlDataReader rdr = cmd.ExecuteReader();

现在我希望使用以加密形式存储在我将使用密码学方法的数据库中的员工编号过滤结果。

现在我被困在如何从SqlDataReader.

我希望返回格式为SqlDataReader,因为要从 CLR 存储过程返回多条记录,只有一种方法SqlContext.Pipe.Send(),并且该方法只接受SqlDataReader对象。

请指导我。

4

1 回答 1

0

我正在研究一个类似的问题,我想在返回结果之前进行一些操作。我目前能看到的唯一方法是使用:

// Note you need to pass an array of SqlMetaData objects to represent your columns
// to the constructor of SqlDataRecord

SqlDataRecord record = new SqlDataRecord();

// Use the Set methods on record to supply the values for the first row of data
SqlContext.Pipe.SendResultsStart(record);

// for each record you want to return
// use set methods on record to populate this row of data

SqlContext.Pipe.SendResultsRow(record);

然后完成后打电话SqlContext.Pipe.SendResultsEnd

如果有更好的方法我也想知道!

于 2011-04-13T08:55:37.417 回答