N
n00m
import socket, thread
host, port = '192.168.0.3', 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()
def VB_SCRIPT():
while 1:
data = cn.recv(4096)
if not data: return
s2.send(data)
print 'VB_SCRIPT:' + data + '\n\n'
def SQL_SERVER():
while 1:
data = s2.recv(4096)
if not data: return
cn.send(data)
print 'SQL_SERVER:' + data + '\n\n'
thread.start_new_thread(VB_SCRIPT,())
thread.start_new_thread(SQL_SERVER,())
=============================================
The above code acts as an intermediator between a very simple VB script
and SQL Server. Like follows:
the vbs sends its requests to "fake" port 1434 and the python code
catches and re-sends them to sql server which listens to its DEFAULT
port = 1433... And vice versa.
=========================================================
VB script:
=========================================================
Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider=sqloledb;Data Source=192.168.0.3,1434;" & _
"Network Library=DBMSSOCN;Initial Catalog=pubs;" & _
"User ID=qwe;Password=asdasd;"
cn.Execute "select * from authors;"
cn.Close
Set cn = Nothing
=========================================================
It works fine (I see all client/server data printed in IDLE window)but
only locally. I.e. if vbs, python and sql server run on the same
machine.
If I run the vbs from some other machine in my LAN then it fails to
work out properly. Below is all that vbs and sql server are able to say
to each other:
===========================================================
VB_SCRIPT:
SERVER qwe asdasd 000000a5 Р·€Ut
Microsoft (r) W 192.168.0.3,1434 asdasd
OLEDB
SQL_SERVER:
Щ 3 г
pubsmaster«0 E # Changed database context
to 'pubs'.W г
us_english «4 G ' Changed language setting to us_english.W г
cp1251  Microsoft SQL Server _ Вг 40964096Ñ
VB_SCRIPT:
G 4096
==========================================================
In abt 30 seconds OLE DB Provider (on the vbs side) reports "General
Network Error".
PEOPLE, WHY ON THE EARTH IT DOES NOT WORK OVER LAN ???
PS:
Of course, without involving Python into the process vbs and sql server
communicate with each other just fine - no matter locally or over LAN;
on win2k machines or on/from NT 4.0 machine.
host, port = '192.168.0.3', 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()
def VB_SCRIPT():
while 1:
data = cn.recv(4096)
if not data: return
s2.send(data)
print 'VB_SCRIPT:' + data + '\n\n'
def SQL_SERVER():
while 1:
data = s2.recv(4096)
if not data: return
cn.send(data)
print 'SQL_SERVER:' + data + '\n\n'
thread.start_new_thread(VB_SCRIPT,())
thread.start_new_thread(SQL_SERVER,())
=============================================
The above code acts as an intermediator between a very simple VB script
and SQL Server. Like follows:
the vbs sends its requests to "fake" port 1434 and the python code
catches and re-sends them to sql server which listens to its DEFAULT
port = 1433... And vice versa.
=========================================================
VB script:
=========================================================
Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider=sqloledb;Data Source=192.168.0.3,1434;" & _
"Network Library=DBMSSOCN;Initial Catalog=pubs;" & _
"User ID=qwe;Password=asdasd;"
cn.Execute "select * from authors;"
cn.Close
Set cn = Nothing
=========================================================
It works fine (I see all client/server data printed in IDLE window)but
only locally. I.e. if vbs, python and sql server run on the same
machine.
If I run the vbs from some other machine in my LAN then it fails to
work out properly. Below is all that vbs and sql server are able to say
to each other:
===========================================================
VB_SCRIPT:
SERVER qwe asdasd 000000a5 Р·€Ut
Microsoft (r) W 192.168.0.3,1434 asdasd
OLEDB
SQL_SERVER:
Щ 3 г
pubsmaster«0 E # Changed database context
to 'pubs'.W г
us_english «4 G ' Changed language setting to us_english.W г
cp1251  Microsoft SQL Server _ Вг 40964096Ñ
VB_SCRIPT:
G 4096
==========================================================
In abt 30 seconds OLE DB Provider (on the vbs side) reports "General
Network Error".
PEOPLE, WHY ON THE EARTH IT DOES NOT WORK OVER LAN ???
PS:
Of course, without involving Python into the process vbs and sql server
communicate with each other just fine - no matter locally or over LAN;
on win2k machines or on/from NT 4.0 machine.