0

What is the simplest way to create a client application(in c++/c#) to communicate with the SQL Server? Since Iam a new-bie and very eager to know how this Database server is managing its connections, requests and responses. I have tried TELNET with the following command assuming that, I can open the connection and write to it.

TELNET <server>  <port>

But the command ends up with a black screen only. Please provide your comments as well as any helpful links.

Playing with HTTP connections was fun, since there was web-browser inspectors(like firebug) to help me:), but here I think things are much difficult & different, (Or if such a tool exists to log TCP connections?)

Vivek Mohan
  • 8,078
  • 8
  • 31
  • 49
  • You do not want to communicate with the server directly - you will use a library or a scripting tool depending on your environment. Please edit retag your question to make your goal and programming language clearer. – Jirka Hanika Jun 12 '12 at 12:14

2 Answers2

2

TDS, the protocol used by SQL Server, is not similar to HTTP or SMTP in that the commands are not sent via text, making it not terribly amenable to usage over TELNET. There's not any easy equivalent to:

GET / HTTP/1.1

There's some documentation on TDS here (from Microsoft), here (from JTDS, a JDBC driver for Sybase and SQL Server), and here (from FreeTDS) if you want to dig into it. If you want to observe the raw packet data, just use some sort client as Jirka Hanika recommended and use Wireshark or another packet-capture tool to observe the data.

Ultimately, if you want to learn something about network protocols, then maybe this worth playing with, but if you want to learn about SQL Server and relational database internals, there are much better places to start than with the network transfer layer, which are incidental to the actual function of databases.

ig0774
  • 39,669
  • 3
  • 55
  • 57
0

For C#, look here. For C++, look here.

Make sure that you are freeing the database connection after use.

Community
  • 1
  • 1
Jirka Hanika
  • 13,301
  • 3
  • 46
  • 75
  • Thank you for your answer. But this is not I need. I need the responses in original format, maximum time taken to establish the connection etc..(tracking full properties of a tcp connection) But here libraries like SqlDataReader, will format the responses and provide result in a dataset format. They will hide every thing from the user. I think I have to look at putty/TELNET client source code to know how they are establishing connections with these servers. – Vivek Mohan Jun 12 '12 at 13:00