Data source for connection string in Web.config

19,246

For me Connection strings could be hard to remember. Its very easy to make a mistake when you write it manually. One advice is to use the server explorer to connect to your database. Then right click on your database icon > select properties ... you will see the connection string copy and paste . Voilà!

If you still have problem then remove the integrated security setting

Server Explorer:

enter image description here

Properties:

enter image description here

Share:
19,246
challengeAccepted
Author by

challengeAccepted

Updated on June 05, 2022

Comments

  • challengeAccepted
    challengeAccepted almost 2 years

    I was wondering what should be the data source for the connection string in Web.config

    My SQL Database explorer looks like 198.57.59.70(SQL Server 10.50.1600 - RAM\ServerAdmin) under which i have databases. When i use this, i get as Network to the database does not exists. When i use Data Source=198.57.59.70, i get an error "System.Data.SqlClient.SqlException: Login failed for user 'RAM\IWPD_3" This is in asp.net 3.5 in Windows server 2008 for deployment. Thank you!

    Can some one guide me, Thank you!!

    <connectionStrings>
        <add name="ConnectionString" connectionString="Data Source=198.57.59.70(SQL Server 10.50.1600 - COMM\ServerAdmin);Initial Catalog=Tracking;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    
  • challengeAccepted
    challengeAccepted almost 11 years
    When i have connectionString="Data Source=198.57.59.70;Initial Catalog=Tracking;Integrated Security=SSPI;" i still get error. I did try the way you told me too. But in vain! :-(
  • challengeAccepted
    challengeAccepted almost 11 years
    I am assuming you did not finish the answer. Isn't it?
  • Sandesh
    Sandesh over 10 years
    but this is possible when you are adding database in your project. Explain what to do when external database is used with project.
  • meda
    meda over 10 years
    @Sandesh external? this should work for everything as long as connected through the wizard, connection string will always be in the properties
  • Sandesh
    Sandesh over 10 years
    @meda I am currently using Sql Server 2005 and 2008 R2 management. Then here How can you find connection string ?
  • meda
    meda over 10 years
    @Sandesh I update my post with screenshot let me know if its helpful.
  • Sandesh
    Sandesh over 10 years
    @meda yes its definitely its helpful.... but will you please tell me how to find conne. string in sql server 2005 like this.
  • meda
    meda over 10 years
    You need the connection string for Visual studio Dont you?
  • meda
    meda over 10 years
    Yes for iternal you would just grab it directly.The example I gave is using external DB, see server explorer screen shot that where you connect to it, use ODBC.