• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 63
  • Last Modified:

C# CLR Stored Procedure

Hi, I have alreday wrote a C# CLR function , it's working without DataReader while loop
for example
SQLDataReader reader=cmd.ExecutedReader();
NOT working
while (reader.Read())
{

firstname=reader[0].tostring();
}



WORKING
SqlContext.Pipe.Send(reader);


I need to pass records using while loop. How to do that ? this is going to call in the Stored Procedure (creating Assembley)
Thnaks
0
lankapala
Asked:
lankapala
1 Solution
 
Ryan ChongCommented:
try look for SendResultsRow instead.

SqlPipe.SendResultsRow Method (SqlDataRecord)
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.server.sqlpipe.sendresultsrow(v=vs.110).aspx

an example is available here but it's using Data Table, but you can adopt same technique for your SQLDataReader

Returning a DataTable over SqlContext.Pipe
http://sharpfellows.com/post/Returning-a-DataTable-over-SqlContextPipe

hope this helps
0
 
lankapalaAuthor Commented:
Thanks Ryan,But the issue is actually not that, i created the DataTable and transferred all the data to the Datattable then passed .It's work after created Datatable. Thanks for you guide
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now