Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does SQL Server return to C#

We can easily work with SQL Server databases with the help of System.Data.SqlClient library in C#.

We can return values from stored procedures or we can write sql commands by hardcoding them in C# code.

Then we pass the result to a SqlDataReader to read the values.

But I am really wondering what SQL Server returns to C#.

C# makes the call to SQL Server and SQL Server gives something (XML, JSON or whatever it is) to C# on return.

What is this thing really? And how can we get only this thing if we want to read it through manually ourselves?

like image 409
tugberk Avatar asked Mar 02 '26 09:03

tugberk


1 Answers

I believe SQL Server at least used to use TDS for its data transfer. I don't know whether it still does - and using it directly would make your code very brittle in the face of changes within SQL Server. The whole point of having client libraries is to isolate you from the intricacies of the protocol.

What benefit are you trying to derive from reading through this manually, over (say) using SqlDataReader, which is about as low-level as most applications will ever need?

like image 50
Jon Skeet Avatar answered Mar 04 '26 23:03

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!