jthompson1
11 years agoContributor
Simple ADO Connect to SQL 2012
I want to connect to a localhost SQLEXPRESS 2012 Database through the use of a script. I have spent far too long trying to accomplish what I would figure to be a simple task. I actually got the connectionstring from TestComplete when I used the wizard to do a data store. TestComplete had no issues connecting via the data wizard. I can also connect to my database using MSSMS, Visual Studio, Toad, web.config... you name it... I cannot connect through a test script.
I get the error : [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied
I've looked at countless articles written by the smartbear team, and am still having issues here. I could use some assistance with this one. Thank you.
function CheckDatabase()
{
var ADOConnection;
ADOConnection = ADO.CreateADOConnection();
ADOConnection.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=noneofyourbusiness;Initial Catalog=master;Data Source=.\sqlexpress"
ADOConnection.CommandTimeout = 60;
ADOConnection.LoginPrompt = false;
try
{
ADOConnection.Open();
Log.Message("Success!!")
}
catch(e)
{
Log.Message(e.message)
}
}