我希望在CLR存储过程中使用加密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对象。
请给我引路。
发布于 2011-04-13 16:55:37
我正在研究一个类似的问题,我想在返回结果之前进行一些操作。目前我能看到的唯一方法是使用:
// 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。
如果有更好的方法,我也想知道!
https://stackoverflow.com/questions/5636136
复制相似问题