Ask a Question

Java script Code for restore database

meghaphophalia
Occasional Contributor

Java script Code for restore database

I write this script for restore database. But getting the error -Login failed for user 'fastreact' .

function To_Restore_DB_FR4()
{
if(Aliases.FR4.Exists)
{
Aliases.FR4.Terminate()
}
var query = "RESTORE DATABASE FR4_Manual_Regression_Apparel FROM DISK = 'C:\\Automation DBs\\FR4_Manual_Regression_Apparel.bak' WITH REPLACE, RECOVERY;"
var AConnection, RecSet;
//Create connection
AConnection = ADO.CreateADOConnection();
//Get the machine name
Source_name=Sys.HostName
//Connection string from Test Complete.
AConnection.ConnectionString = AConnection.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=master;Data Source="+Source_name+"\\SQLEXPRESS;User Id=fastreact;Password=";
AConnection.LoginPrompt = false;
AConnection.Open();
Delay(2000)
// Execute a simple query
RecSet = AConnection.Execute_(query);
//Close DB connection
AConnection.Close();
Delay(2000)

}

 

Not able to debug what is the exact issue .Also these steps are running manually at my side .

Database is master and User fastreact is there .There is no password set for this.

4 REPLIES 4
Marsha_R
Community Hero

Does that user name in fact have permissions to connect to the database?  Does it work if you do the connnection from a db tool?


Marsha_R
[Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
meghaphophalia
Occasional Contributor

Yes,it work if I do the connnection from a db tool
The information contained in this communication (including any attachments transmitted with it) is confidential and may be privileged and the views, conclusions and other information expressed herein are not necessarily the views of or endorsed by Coats Group plc unless such information is transmitted in the normal course of its business. It is for the exclusive use of the intended recipient(s). If you have received this message in error and you are not the intended recipient(s), please notify us by email (Technology.Supportdesk@coats.com) or telephone our technical support helpdesk at Coats Group plc. +44 (0)208 606 6656 (available 24 hours a day, 7 days a week) and then delete the email and any copies of it including any attachments thereto. Any distribution, copying or use of this communication or the information contained herein if received in error is strictly prohibited. Coats Group plc will not be liable for direct, special, indirect or consequential damages arising from the alteration of the contents of this message by a third party or as a result of any virus being passed on. All references to "Coats Group plc" includes all of its subsidiaries and associated companies. Coats Group plc is registered in England and Wales under company registration number 00103548 having its registered office at 4 Longwalk Road, Stockley Park, Uxbridge UB11 1FE.
VirginiaSus3
Occasional Contributor

bak' which is available in 'D:\' location if you are overwriting the existed database. If you are creating a new database with this restore command and there is no similar path of data, log files in target server, then use move option like the following command.
it('should return validation error if metric type is invalid', async () => {  sinon.stub(Metric.prototype, 'insertDatapoints').returns([])  sinon.stub(MetricsStoreProxy.prototype, 'get').returns(new Metric({metricID: '1', type: 'Mock'}))  sinon.stub(MockService.prototype, 'shouldAdminPostDatapoints').returns(false)
  const id = 123
  await handle({[id]: []}, null, (error, result) => {   error = JSON.parse(error)   assert(error.length === 1)   assert(error[0].message.match(/Mock/))  })
  MockService.prototype.shouldAdminPostDatapoints.restore() })

 

rraghvani
Frequent Contributor

Are you able to query a table, for example.

function test()
{
	var conn = ADO.CreateConnection();
	conn.ConnectionString = ""; // Use correct database connection string, https://www.connectionstrings.com/microsoft-ole-db-provider-for-sql-server-sqloledb/
	conn.Open();
	// If the query fails, then database connection string is incorrect
	conn.Execute("SELECT * FROM table_name;");
	conn.Close();
}

 This is just to test that the database connection string is correct

cancel
Showing results for 
Search instead for 
Did you mean: