How do I programmatically communicate with a remote SQL Server

  • I am attempting to communicate with a SQL Server instance on a remote server but haven't had any success so far. The code I'm attempting to execute is as follows:

    TcpClient client = new TcpClient("10.23.79.98", 1433);

    NetworkStream stream = client.GetStream();

    StreamWriter sw = new StreamWriter(stream);

    byte[] bytes = new byte[1024];

    int bytesRead = stream.Read(bytes, 0, bytes.Length);

    My app hangs when it attempts to execute the last line. I know I'm using the correct IP address and that port 1433 on the server is listening; I also know the client is connected because the client.Connected property returns true after executing the first statement. But I don't know where to go from here, nor do I know what I need to do to establish communication with SQL Server itself, the connection string being something along the line of:

    Persist Security Info=false;Integrated Security=true;Initial Catalog=VZMonitor;Server=chaitsmon126

    Can someone help me with this roadblock? Much thanks in advance.

    Allen

  • Are you trying to build something to read TDS streams?

    I might start here: http://msdn.microsoft.com/en-us/library/ms191220.aspx

    or drop a note on this blog: http://blogs.msdn.com/sql_protocols/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply