CLR 存储过程

发布于 2024-10-31 15:40:52 字数 642 浏览 5 评论 0原文

我希望在 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 对象。

请指导我。

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 for 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩世 2024-11-07 15:40:52

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

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

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

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文