on error resume next
'Author: MAK
'Contact: mak_999@yahoo.com
'Date March 30, 2005
'Check Connectivity
'Usage: testconnectivity.vbs Servername dbname Loginname Password
Set objArgs = WScript.Arguments
Server= objArgs(0)
database= objArgs(1)
uid=objArgs(2)
pwd=objArgs(3)
Set AdCn = CreateObject("ADODB.Connection")
Set AdRec = CreateObject("ADODB.Recordset")
connstr="Provider=SQLOLEDB.1;Data Source=" & server & ";Initial Catalog=" & database & ";user id = '" & uid & "';password='" & pwd & "'"
'msgbox connstr
'AdCn.Open = "Provider=SQLOLEDB.1;Data Source=sssss;Initial Catalog=weeklyreboot;user id = 'rebootuser';password='reboot123' "
AdCn.Open = connstr
SQL="Select @@version as name"
AdRec.Open SQL, AdCn,1,1
xxx=Adrec("name")
if err.number <> 0 or left(xxx,5)<>"Micro" then
msgbox "Can't connect"
else
msgbox "connected"
end if
No comments:
Post a Comment
Hi,
Thanks for your visit to this blog.
We would be happy with your Queries/Suggestions.