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
LVL 2
lankapalaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.