N
n00m
In a simple VB script I open ADODB.Connection and start sending
some very simple T-SQL commands to a MS SQL Server. Like this:
------------------------------------------------------------
Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider=sqloledb;Data Source=127.0.0.1,1434;" & _
"Network Library=DBMSSOCN;Initial Catalog=pubs;" & _
"User ID=qwe;Password=asdasd;"
cn.Execute _
"select 'XXXXXXXXXXXX';" & _
"waitfor delay '00:00:03'; raiserror ('AAA',10,1) with nowait;" & _
"waitfor delay '00:00:03'; raiserror ('BBB',10,1) with nowait;" & _
"waitfor delay '00:00:03'; raiserror ('CCC',10,1) with nowait;" & _
"waitfor delay '00:00:03'; select 'YYYYYYYYYYYY';"
------------------------------------------------------------
BUT I do it (sending to\fro data) via two sockets opened in a python
code. Note: in above connection string I direct VB script to port 1434,
BUT the SQL Server listens to its default port = 1433.
Here my python code:
------------------------------------------------------------
import socket
host, port = '127.0.0.1', 1434
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((host, 1433))
s1.bind((host, port))
s1.listen(1)
cn, addr = s1.accept()
while 1:
data = cn.recv(4096)
if not data: break
s2.send(data)
print 'VB_SCRIPT:', data
data = s2.recv(4096)
if not data: break
cn.send(data)
print 'SQL_SERVER:', data
cn.close()
s1.close()
s2.close()
------------------------------------------------------------
And in the 0-approximation everything works just fine! I can
see printed intercepted requests\replies from VBS\SQLServer.
BUT alas it does not work EXACTLY as it works if the VB script
"connects" DIRECTLY to the "true" SQL Server's port = 1433.
After receiving the first error_message 'AAA' the VBS should
immediately issue something like 'Ready to receive next packet'
(in my newbish understanding), BUT instead it gets frozen till
its CommandTimeout times out and only then it wakes up, issues
a final request and gets ALL data that SQL Server "accumulated"
for the client's side; namely, error_messages 'BBB' and 'CCC'
and result of "select 'YYYYYYYYYYYY'".
ANY IDEAS WHY IT WORKS NOT QUITE CORRECTLY WILL BE GREATLY
APPRECIATED!!!
some very simple T-SQL commands to a MS SQL Server. Like this:
------------------------------------------------------------
Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider=sqloledb;Data Source=127.0.0.1,1434;" & _
"Network Library=DBMSSOCN;Initial Catalog=pubs;" & _
"User ID=qwe;Password=asdasd;"
cn.Execute _
"select 'XXXXXXXXXXXX';" & _
"waitfor delay '00:00:03'; raiserror ('AAA',10,1) with nowait;" & _
"waitfor delay '00:00:03'; raiserror ('BBB',10,1) with nowait;" & _
"waitfor delay '00:00:03'; raiserror ('CCC',10,1) with nowait;" & _
"waitfor delay '00:00:03'; select 'YYYYYYYYYYYY';"
------------------------------------------------------------
BUT I do it (sending to\fro data) via two sockets opened in a python
code. Note: in above connection string I direct VB script to port 1434,
BUT the SQL Server listens to its default port = 1433.
Here my python code:
------------------------------------------------------------
import socket
host, port = '127.0.0.1', 1434
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((host, 1433))
s1.bind((host, port))
s1.listen(1)
cn, addr = s1.accept()
while 1:
data = cn.recv(4096)
if not data: break
s2.send(data)
print 'VB_SCRIPT:', data
data = s2.recv(4096)
if not data: break
cn.send(data)
print 'SQL_SERVER:', data
cn.close()
s1.close()
s2.close()
------------------------------------------------------------
And in the 0-approximation everything works just fine! I can
see printed intercepted requests\replies from VBS\SQLServer.
BUT alas it does not work EXACTLY as it works if the VB script
"connects" DIRECTLY to the "true" SQL Server's port = 1433.
After receiving the first error_message 'AAA' the VBS should
immediately issue something like 'Ready to receive next packet'
(in my newbish understanding), BUT instead it gets frozen till
its CommandTimeout times out and only then it wakes up, issues
a final request and gets ALL data that SQL Server "accumulated"
for the client's side; namely, error_messages 'BBB' and 'CCC'
and result of "select 'YYYYYYYYYYYY'".
ANY IDEAS WHY IT WORKS NOT QUITE CORRECTLY WILL BE GREATLY
APPRECIATED!!!