Home > database >  About the test used to connect
About the test used to connect

Time:09-28

Need timing judgment is essentially connectivity in program, I find the code on the net, or more useful, but in some machines have a problem, the code is as follows:
.
The connection myconnect
Myconnect=create connection
Myconnect. Driver="WinSock"
Myconnect. Application="1433"
Myconnect. Location=vs_servername
Li_return=myconnect. ConnectToServer ()
.
Usually can return to zero, but sometimes return to 55, for some reason, thank you

CodePudding user response:

Also can use a simple SQL to test!

CodePudding user response:

The machine is generally ok.

CodePudding user response:

1. Not even a native, even the server
2. Use SQL directly measure will wait long timeout, intolerable

CodePudding user response:

refer to the original poster yjfan response:
program need timing judgment is essentially connectivity, I find the code on the net, or more useful, but in some machines have a problem, the code is as follows:
.
The connection myconnect
Myconnect=create connection
Myconnect. Driver="WinSock"
Myconnect. Application="1433"
Myconnect. Location=vs_servername
Li_return=myconnect. ConnectToServer ()
.
Usually can return to zero, but sometimes return to 55, for some reason, thank you

Behind the lines of code=5 quotes and have a look

CodePudding user response:

Take a look at that...

CodePudding user response:

Behind the lines of code=5 quotes?
Behind the vs_servername is variable, the value must be no problem, I directly use IP address is also not line, on several other machine is normal, should be caused by environment, complete code is as follows:

The integer li_return
String ls_rtn

/* * * * * * * to find the network whether there is any input the name of the server * * * * * * * * * */
The connection myconnect
Myconnect=create connection
Myconnect. Driver="WinSock"
Myconnect. Application="1433"
Myconnect. Location=vs_servername
Li_return=myconnect. ConnectToServer ()
If li_return=52 then
Ls_rtn="in the network without you to enter the host name, please confirm and re-enter!"
Return ls_rtn
End the if
/* * * * * * * * * * * * * * * * * END * * * * * * * * * * * * * * * * */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
To judge whether the SQL Server has been started, if does not start to do the corresponding processing
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
OLEObject PBObject, PBDATEBASE
Long ll_status

PBObject=CREATE OLEObject
Ll_status=PBObject. ConnectToNewObject (" SQLDMO. Essentially ")
IF ll_status=0 THEN//connection success
Pbobject. Name=vs_servername
Pbobject. Logintimeout=5
//pbobject. LoginSecure=True//to connect NT way
Pbobject. LoginSecure=false//in SQL Server connection

Li_return=PBOBJECT. Status
If li_return=2 then//SQL Server to hold
If vb_autostart then
PBOBJECT. Continue ()
The else
Ls_rtn='database services have been suspended'
Return ls_rtn
End the if

Elseif li_return=3 then//SQL Server to stop state
If vb_autostart then
PBOBJECT. Start (false, vs_servername vs_username, vs_password)//Start the SQL Server
The else
Ls_rtn='database service has stopped'
Return ls_rtn
End the if
End the if
The ELSE
Ls_rtn="database connection failed! ~ n please check the input user name and password is correct, "
Return ls_rtn
End the if
/* * * * * * * * * * * * * * * END * * * * * * * * * * * * * * * * */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Due to start the SQL Server need some time, so wait for essentially start
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

LI:
Li_return=PBOBJECT. Status
IF li_return & lt;> 1 THEN//no 1 (not running state)
GOTO LI
The ELSE//to 1, connect to the database
//PBOBJECT. CONNECT (ls_servername ls_username, ls_password)
DESTROY PBObject//DESTROY objects
Return '
END the IF
/* * * * * * * * * * * END * * * * * * * * * * */

I don't know and SQLDMO. Is there a link between the DLL, I registered several times it would be useless

CodePudding user response:

Sometimes returns 0 returned 55 55 is request are sometimes unexpected termination might as well look for reasons from another Angle

CodePudding user response:

Not sometimes, it is 55 100% return on a server, another one on the server is normal, together with two machines, if do not have what distinction!

CodePudding user response:

This problem also need

CodePudding user response:

Telnet to connect?

CodePudding user response:

Telnet can even
In front of it doesn't matter, the key is the li_return=PBOBJECT. Status error

CodePudding user response:

Ha ha,, PBObject. ConnectToNewObject (" SQLDMO. Essentially ")
Is essentially a built-in object, you need to install used to call, so if you're not installed is essentially machines will connect SQLDMO object is not successful, you have to decide whether it return values, methods I have written to you in another post, go and see you,

CodePudding user response:

Such as firewalls can also affect the back of the statement, if is to use the name of the machine NETBIOS protocol will also be influential in
Pbobject. Name=vs_servername possible failure
There is a way to test, you through the failure of the program is run on the machine service manager to use it, in the server list to choose your database server, one can see the state read;

For connecttonewobject reference function calls, advice and try.. Catch statement

CodePudding user response:

Thank you, but my machine is equipped with essentially, and sqldmo is registered, I use the try... The catch was useless, to li_return=PBOBJECT. The Status it still error,
Also: I find in the object browser of pb programmable object cannot find sqldmo ah, how to return a responsibility?

I use API service status, later removed correctly on Windows xp, but take not to come out on 2003 server, can I see another post,
Again, thank you!

CodePudding user response:

Ha ha, the first time I heard said try catch useless ~ ~
On the 14th floor yjfan
reference response:
thank you, but my machine is equipped with essentially, and sqldmo is registered, I use the try... The catch was useless, to li_return=PBOBJECT. The Status it still error,
Also: I find in the object browser of pb programmable object cannot find sqldmo ah, how to return a responsibility?

I use API service status, later removed correctly on Windows xp, but take not to come out on 2003 server, can I see another post,
Again, thank you!
nullnullnullnullnullnullnullnullnullnullnullnull
  • Related