0

At work I wrote an application that processes data from a SQL Server database and outputs it in file format.

Now I need to use it at home and since app has hard-coded connection string I've got a problem. I got a copy of database at my company, the original database is inaccesable from the outside of the company.

Connection string format looks like this

Data Source=serverName-01;Initial Catalog=dbName_01;Integrated Security=True;Pooling=False

I've tried to cheat app by editing windows hosts file:

serverName-01 127.0.0.1

But it did not work. Is there a way to make it work without going to work and editing source code ?

Lesson learned hard way - never hard-code connection srings :<

4
  • Your company is so generous to take the source code at home? Commented Mar 22, 2013 at 12:49
  • I got source code, but project uses some liblaries that I cannot legaly install at home. Commented Mar 22, 2013 at 12:52
  • All you can do is install a local database with the exact same servername and db schema. Commented Mar 22, 2013 at 12:52
  • Tried it SQL-server does not allow to use '-' character in name. '-' in company domain computer name Commented Mar 22, 2013 at 12:54

1 Answer 1

1

To do this you can use an alias defined in SQL Server Configuration manager. Create an alias for your local instance that has the exact same name as the one in the connection string.

Have a look at the following article for how to do this (it's pretty simple):

Create or Delete a Server Alias for Use by a Client (SQL Server Configuration Manager)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.