Database Connection String Info

前端 未结 6 1266
误落风尘
误落风尘 2020-12-31 10:55

In .Net is there a class in .Net where you can get the DB name, and all the connection string info without acutally doing a substring on the connection string?

EDIT:

6条回答
  •  醉酒成梦
    2020-12-31 10:59

    SqlConnection sq = new SqlConnection(ConnectionString);
    

    Reference

    Done with "using" statement (from MSDN)

    using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();
            // Do work here; connection closed on following line.
        }
    

提交回复
热议问题