简体   繁体   English

与SQL Server的Telnet连接

[英]Telnet connection with SQL Server

What is the simplest way to create a client application(in c++/c#) to communicate with the SQL Server? 创建客户端应用程序(在c ++ / c#中)与SQL Server通信的最简单方法是什么? Since Iam a new-bie and very eager to know how this Database server is managing its connections, requests and responses. 因为Iam是一个新人,非常渴望知道这个数据库服务器如何管理它的连接,请求和响应。 I have tried TELNET with the following command assuming that, I can open the connection and write to it. 我用以下命令尝试了TELNET,假设我可以打开连接并写入它。

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?) 使用HTTP连接很有趣,因为有网络浏览器检查员(像firebug)来帮助我:),但在这里我认为事情很难和不同,(或者,如果存在这样的工具来记录TCP连接?)

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. TDS,SQL Server使用的协议,与HTTP或SMTP不相似,因为命令不是通过文本发送的,因此不太适合通过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. 这里有一些关于TDS的文档(来自Microsoft)这里(来自JTDS,一个用于Sybase和SQL Server的JDBC驱动程序) ,以及这里(来自FreeTDS),如果你想深入研究它。 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. 如果您想观察原始数据包数据,只需使用Jirka Hanika推荐的某种排序客户端,并使用Wireshark或其他数据包捕获工具来观察数据。

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. 最后,如果你想学习一些关于网络协议的东西,那么这可能值得一试,但如果你想了解SQL Server和关系数据库内部,那么有更好的起点比网络传输层更好,这是偶然的到数据库的实际功能。

For C#, look here . 对于C#, 请看这里 For C++, look here . 对于C ++, 请看这里

Make sure that you are freeing the database connection after use. 确保在使用后释放数据库连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM