cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to connect to my local db

New Contributor

Unable to connect to my local db

Error thrown when I am trying to restore my local DB using ADO object available in Testcomplete

 

Here is my full script

(Written in Jscript)

var con,query,result;
  con=ADO.CreateADOConnection();
  
  con.ConnectionString = "Provider=SQLNCLI11;Server=mylocalserver;Database=MyLocalDB;Integrated Security=True;DataTypeCompatibility=80;Uid=sa;Pwd=123123;";
  
  con.Open();
  query=ADO.CreateADOQuery();
  query.SQL="RESTORE DATABASE MyLocalDB FROM DISK = 'C:\\Test\\TestsBackup\\Data\\DB\\MyLocalDB.bak' WITH REPLACE";
  query.Active=con;
  result=query.ExecSQL();
  con.Close();

 When executing throws an below error,

 

 Capture.PNG

 

5 REPLIES
Community Hero

Re: Unable to connect to my local db

Hi,

 

a) The message does not say that ADO cannot connect to the database. It says that the system is out of resources. It's better to reboot.

b) ADO Query object assumes that a recordset is returned, while your SQL will not return a recordset. Not sure about ADO wrapper in TestComplete, but in 'pure' ADO you should use Command object instead of Recordset in this case.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Manager

Re: Unable to connect to my local db

Thanks for sharing your suggestions, Alex.

@DKumar04, did Alex reply help you overcome the error message? If it did, please accept his reply as a solution.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Contributor

Re: Unable to connect to my local db

Thanks for the post Alex. 

Still issue not sorted out.

Please post me the JScript for restoring my local db 

Community Hero

Re: Unable to connect to my local db

Hi,

 

As one of possible options: https://support.smartbear.com/viewarticle/8968/

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: Unable to connect to my local db

For restoring the database you must switch first to master db than only restore will work and current script seems to be trying to connect to same db
best way you can use sqlcmd by creating sql file to restore database and run it from batch cmd
add that batch file in the testcomplete.
2018 NEWS
Top Kudoed Authors