Jim tan

Jim tan

  • NA
  • 29
  • 584

Access Data from DB which its constring located in registry

Nov 16 2021 4:15 PM

Hello ,

I am working on a windows Form in C# to get some data from an external application that has an SQL Connection String Saved in the registry, since it is an external applciation we are obliged to use the Connection String from Registry to connect to its DB.

My question is how to get the data needed from Specific table by connecting to this DB from this Connection String and display the results in a DataGridView.

As a note : the connection string contains as well the user name and Password .

I know how  to display data when we have the connection string in an app.config file or in a local DB.

We can maybe use the below function to get the value of the connection string , but I don't know how to move forward

string text = registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\myappname", "CONNECTIONSTRING"). and we create a query to the Db " Select *from tablex valueabc...

Appreciate your help and ideas

Regards,

Jim


Answers (3)