开发者

CLR Stored Procedure

I wish to use the Cryptography API in CLR stored procedure.

I have created a CLR stored procedure and written a select statement

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();

Now I wish to filter the results using the employee Number which is stored in encrypted form in database f开发者_Go百科or which I am going to use the Cryptography methods.

Now I am stuck with how to go about filtering the records from the SqlDataReader.

I want the return format as SqlDataReader, as to return multiple records from CLR stored procedure there is one method SqlContext.Pipe.Send() and this method accepts only SqlDataReader objects.

Please guide me.


I'm looking at a similar problem where I want to do some manipulation before returning the results. The only way I can see at the moment is to use:

// 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);

Then call SqlContext.Pipe.SendResultsEnd when you're done.

If theres a better way I'd like to know too!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜