Bulk changing SQL database for all SQL datasources

Best practices, code snippets for common functionality, examples, and guidelines.
sdrx
Posts: 8
Joined: Tue Jan 29, 2019 10:15 am

Bulk changing SQL database for all SQL datasources

Post by sdrx » Thu Jul 11, 2019 9:35 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5154
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Bulk changing SQL database for all SQL datasources

Post by odklizec » Thu Jul 11, 2019 9:41 am

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!
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sdrx
Posts: 8
Joined: Tue Jan 29, 2019 10:15 am

Re: Bulk changing SQL database for all SQL datasources

Post by sdrx » Thu Jul 11, 2019 9:46 am

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5154
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Bulk changing SQL database for all SQL datasources

Post by odklizec » Thu Jul 11, 2019 10:39 am

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 ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sdrx
Posts: 8
Joined: Tue Jan 29, 2019 10:15 am

Re: Bulk changing SQL database for all SQL datasources

Post by sdrx » Thu Jul 11, 2019 11:22 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5154
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Bulk changing SQL database for all SQL datasources

Post by odklizec » Thu Jul 11, 2019 11:59 am

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 ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sdrx
Posts: 8
Joined: Tue Jan 29, 2019 10:15 am

Re: Bulk changing SQL database for all SQL datasources

Post by sdrx » Thu Jul 11, 2019 2:32 pm

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

sdrx
Posts: 8
Joined: Tue Jan 29, 2019 10:15 am

Re: Bulk changing SQL database for all SQL datasources

Post by sdrx » Thu Jul 11, 2019 2:49 pm

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).