Page 1 of 1

Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 9:35 am
by sdrx
Hello, I have a solution that has a large amount of SQL datasources across multiple test suites. Currently it points at one database but in future there will be a need to have it point to another database with the same table structures etc but just a different database name.

Is there a way to mass update all the SQL data sources to have a different database IE: in the "Connection Properties" window under the "Connect to a database name" drop down?

Perhaps a way to mass update all the connection strings for all SQL datasources would be better as that will cover for the possibility of changes to servers as well.

Thanks in advance.

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 9:41 am
by odklizec
Hi,

I think the easiest way would be to edit the rxtst file in a good text editor and simply find&replace all necessary strings. At least this is how I'm doing similar bulk changes ;) Of course, you should do this only after properly backuping solution to version control system of your choice!

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 9:46 am
by sdrx
That is a good idea but it might not be a suitable option as there are 188 test suites so far :(

Although your suggestion has given me an idea to maybe get some C# together to perform a find and replace in the RXTST files maybe based on a simple data connector. I wonder if that would work?

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 10:39 am
by odklizec
Hi,

Good text editors, like Notepad++ or PSPad, allows search&replace operations in files. So I think doing this kind of bulk operation via custom code is possible, but not quite necessary ;)

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 11:22 am
by sdrx
I was thinking there would be a reasonably easy way to update these in bulk via code.

None of the SQL would change, just the connection string itself and it would need changed for all the datasources at once.

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 11:59 am
by odklizec
Well, I think that such simple change would be really simple with search&replace in files, as I mentioned before. I would really not complicate such a thing with potentially failing custom code, while good programing editors are debugged for many years ;)

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 2:32 pm
by sdrx
The main issue is that there are 188 test suites each with a variety of data sources, some SQL, some not. Possibly about 80 different SQL data connectors.

It does look like another users have had issues with this here with some form of reply:
https://www.ranorex.com/forum/multiple- ... t7676.html
https://www.ranorex.com/forum/dynamical ... t5867.html

Re: Bulk changing SQL database for all SQL datasources

Posted: Thu Jul 11, 2019 2:49 pm
by sdrx
I think a combination the information on those two threads has solved it. The issue I had is that I didn't realise it would only set the connection string for that particular run (rather than changing it persistently).