7
Answers

How do I know what is the connection String?

Photo of Tangara G

Tangara G

8y
272
1
Hi,
 
I used to work with entity framework and I need not worry what is the connection String blah blah blah.
 
But now, I have to use ADO.net framework I do not know how to write the Connection String based on the Ms SQL Server 2016 I am using.
 
Can someone tells me from where I can know information on the above?

Answers (7)

1
Photo of Nitin Sontakke
NA 11.7k 2.2k 8y
Looks like i misread your question. Now I got it.
 
First thing is, are you been able to connect to SQL Server through Management Studio. If yes, you should have user Id, password and a database name.
 
After you succeed in doing above, you can use answer given by Abhilash.
 
The fact that you are talking about Server Properties, probably you have logged in. If yes, did you not use user Id and password? If not, you probably logged in using Windows Authentication.
 
If you are using Windows Authentication, your connection string would be
 
connectionString="Server=SQlServerName;Database=YouDatabaseName;Trusted_Connection=True;"
 
 
Accepted
2
Photo of Nitin Sontakke
NA 11.7k 2.2k 8y
I cannot buy that you didn't have to worry about connection string while using EF. How were you creating the context? You must definitely had a context name.
 
If yes, go in web.config and you will find a connection string named after your context name there.
 
2
Photo of Bikesh Srivastava
NA 19.8k 835.1k 8y
Go=>Tools=>Connect   to database=>new window will be open fill details.
click on ok=>go=>server explorer=.right click=>check property=>connection string,,,that's it 
2
Photo of Mani Kandan
NA 2.6k 135.7k 8y
Try this inside Web.Config file.
 
  1. <configuration>  
  2.  <connectionStrings>  
  3.    <add name="SQLDbConnection"  
  4.         connectionString="Server=SQlServerName; Database=YouDatabaseName; User Id=userid; password= password"  
  5.         providerName="System.Data.SqlClient" />  
  6.  </connectionStrings>  
  7. </configuration>  
 
0
Photo of Dilip Gupta
NA 348 45 8y
   follow this link for more information:
 
https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx 
0
Photo of Tangara G
NA 265 23.9k 8y
Hi Nitin,
 
I am not using EF so there is no context whatsoever.
 
So, I have to connect directly to the dataSource which is Ms SQL 2016 but I do not know what to put at the Connection String DataSource there at the web.config.
 
Can you pls advise me ?
 
0
Photo of Tangara G
NA 265 23.9k 8y
Hi Abhilash,
 
 
Can I know YourDatabaseName is it referring to the name in the Server Properties ?
 
Cos the Server Properties it is using my name....
Also, is it necessary to put in User Id and password ? 
Where can I find my User Id and password in the system ?
 
Pls clarify.
Tks.