locked
how to use connection string from configuration with table adapter RRS feed

  • Question

  • User-102500655 posted

    hi everyone i am using strongly typed data table and table adapter in my DAL to access database.. i want to save my connection string in config file or want to use already created connecting strings from config where while creating tableadapter it shows connecting strings from settings..and save new connection strings in settings too..

    any help??

    Wednesday, September 14, 2011 6:47 AM

Answers

  • User1135668169 posted

    Assuming that you are asking how to use Connection String from Web.config file.

    Here is the code

    using System.Data.SqlClient;
    using System.Configuration;
     SqlDataAdapter ad;
    SqlCommand cmd;
    System.Data.DataTable ds;
    SqlConnection conn = new SqlConnection();
    conn.ConnectionString = ConfigurationManager.ConnectionStrings["Employee"].ConnectionString;
    conn.Open();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 14, 2011 6:53 AM
  • User-102500655 posted

    folowing link help me to find out my answer may help somebody else

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/7483b816-be7a-4204-a4d3-cfb14b2aae26

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 15, 2011 2:22 AM

All replies

  • User1135668169 posted

    Assuming that you are asking how to use Connection String from Web.config file.

    Here is the code

    using System.Data.SqlClient;
    using System.Configuration;
     SqlDataAdapter ad;
    SqlCommand cmd;
    System.Data.DataTable ds;
    SqlConnection conn = new SqlConnection();
    conn.ConnectionString = ConfigurationManager.ConnectionStrings["Employee"].ConnectionString;
    conn.Open();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 14, 2011 6:53 AM
  • User-102500655 posted

    but i am not creating adapter dynamically i create this through wizard..as strongly typed datatables are created...

    Wednesday, September 14, 2011 7:51 AM
  • User-102500655 posted

    folowing link help me to find out my answer may help somebody else

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/7483b816-be7a-4204-a4d3-cfb14b2aae26

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 15, 2011 2:22 AM