Ask a Question

Unable to connect to my local db

DKumar04
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 5
AlexKaras
Champion Level 3

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 Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
TanyaYatskovska
SmartBear Alumni (Retired)

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 Yatskovskaya
SmartBear Community and Education Manager



Thanks for the post Alex. 

Still issue not sorted out.

Please post me the JScript for restoring my local db 

Hi,

 

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

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
anupamchampati
Frequent Contributor

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.
cancel
Showing results for 
Search instead for 
Did you mean: