robertwolfheart
robertwolfheart

Reputation: 107

SQL Server no source code, wanting to change the connection string

I've this situation with a web application:

-I don't have the source code -We need to change the database server ASAP -In order for the application to work, we need to change the connection string or find a workaround for this

It's a .NET 1.1 application, and the connection string is into a .dll. ¿What options do I have? The last time we changed the server, we put everything in the same server(including the database server) and then we added the ip of the database server to the new server... but this is not possible now because the database server will be hosted in other place.

Is there some way to "emulate" the ip of the last server?

What else can I do?

Upvotes: 0

Views: 163

Answers (2)

Alejandro
Alejandro

Reputation: 7829

If the connection string is hardcoded into the .DLL, and if it uses a name to reference the server (not its IP), you might want to change the hosts file on the server running the web site if you have access, so it points to the new DB server instead. Another choice may be to using the alias feature of the SQL native client to redirect the connection to somewhere else. But if the connection string uses an IP address, I don't think those methods would work. Changing the local IP address of the web server might allow some other server to take its place instead, again, if you have that kind of access. Nothing is 100% reliable if you can't really change the connection string.

In the long run, I think the best chance is if you can try to disassemble the DLL and modify the connection string so that its read from some configuration file, instead of being hardcoded, then recompile and from then on modify the parameters from the config.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1503809

Assuming the DLL is a .NET DLL too, I'd consider the following:

  • Run ildasm to disassemble the DLL into IL
  • Edit the IL to change the connection string
  • Run ilasm (a .NET 1.1 version!) to reassemble the IL into a DLL
  • Make it very, very clear to management that you're in an unsustainable situation. You really can't run a production web site in this sort of state.

Upvotes: 2

Related Questions