locked
Sql Server connection strings.... How to you format for using a User ID= / Password= RRS feed

  • Question

  • User2130491911 posted

    Hi All,

    I mostly use Integrated Security, mostly.... but now I have a need to use a connection string with a user name and password and I am not sure how it should be formatted...

    Do you need quoted arounf the user name and password... not of the MS connection string examples are helpful as they don't say if you should or should not

    here is my example:

     <add name="EF_DB_Entities" connectionString="metadata=res://*/EF.EF_DB_Model.csdl|res://*/EF_DATA.EF_DB_Model.ssdl|res://*/EF_DATA.EF_DB_Model.msl;provider=System.Data.SqlClient;provider connection string='data source=&quot;SERVERDB, 10&quot;;initial catalog=EF_DB; User ID=DOM\XX_XXUser; Password=A123A1213; MultipleActiveResultSets=True;App=EntityFramework'" providerName="System.Data.EntityClient" />
    

    Should this : User ID=DOM\XX_XXUser; Password=A123A1213;

    be This :  User ID="DOM\XX_XXUser"; Password="A123A1213";

    It is not 100% clear from the help examples I found  Thanks in advance!

    Tuesday, December 4, 2018 11:01 PM

Answers

  • User475983607 posted

    Make a connection using either "SQL Server Object Explorer" or "Server Explorer" in Visual Studio.  Both Views are found in the View dropdown menu in Visual Studio.

    Click theBoth Views have a connection icon where you can use a GUI to connect.  Finally copy the connection string from the connection properties window.  Properties is also a View if not already present in Visual Studio.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2018 12:17 AM
  • User-1716253493 posted

    Create a page, in design mode add sqldatasurce, configure it by creating new connection till finish.

    In middle wizard you will asked to save connection, save it, you will get it in web.config after finish.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2018 1:16 AM
  • User364663285 posted

    Try to put this

    	<connectionStrings>
    		<add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
    	</connectionStrings>
    


    within Web.config/app.config file in your project, to ensure the project will work fine with the database.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2018 5:01 AM
  • User-893317190 posted

    Hi AppDev01,

    You could create a new Ado.Net Entity Data Model ,on the wizard, click new connection, then change authentication to SQL Server Authentication,enter your username and password,finally click ok, visual studio will automatically add the connection string to your web.config.

    Best Regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 6, 2018 5:47 AM

All replies

  • User475983607 posted

    Make a connection using either "SQL Server Object Explorer" or "Server Explorer" in Visual Studio.  Both Views are found in the View dropdown menu in Visual Studio.

    Click theBoth Views have a connection icon where you can use a GUI to connect.  Finally copy the connection string from the connection properties window.  Properties is also a View if not already present in Visual Studio.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2018 12:17 AM
  • User-1716253493 posted

    Create a page, in design mode add sqldatasurce, configure it by creating new connection till finish.

    In middle wizard you will asked to save connection, save it, you will get it in web.config after finish.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2018 1:16 AM
  • User364663285 posted

    Try to put this

    	<connectionStrings>
    		<add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
    	</connectionStrings>
    


    within Web.config/app.config file in your project, to ensure the project will work fine with the database.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2018 5:01 AM
  • User-893317190 posted

    Hi AppDev01,

    You could create a new Ado.Net Entity Data Model ,on the wizard, click new connection, then change authentication to SQL Server Authentication,enter your username and password,finally click ok, visual studio will automatically add the connection string to your web.config.

    Best Regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 6, 2018 5:47 AM