A
A
Arthur2016-07-23 16:22:50
ASP.NET
Arthur, 2016-07-23 16:22:50

How to make an ADO.NET request without specifying a database?

Hello. I use ASP.NET MVC 5, developing on the local machine in the request from the code I used the following format (ADO.NET):
SELECT * FROM [DataBase].[dbo].[Technologies]
Connection String:

<add name="main" connectionString="Data Source=PC;Initial Catalog=DataBase;Integrated Security=True;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" providerName="System.Data.SqlClient"/>\

Now it's time to throw it out for release, and I came across the fact that the server has a different name for the database, so everywhere in the code you need to change [DataBase] to [ServerDataBase].
I googled it and saw that you can specify Initial Catalog in the connection string, but when I put the name of the database there, I get an error.
In general, I need to come to a similar format:
SELECT * FROM [dbo].[Technologies]
or even better
SELECT * FROM Technologies
How?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-07-23
@r3st1k25

Initial Catalog=DataBase
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question