Database Connection String Info

前端 未结 6 1262
误落风尘
误落风尘 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

    ConnectionInfo connectionInfo = new ConnectionInfo ();
    connectionInfo = logOnInfo.ConnectionInfo;
    
    connectionInfo.DatabaseName = database;
    connectionInfo.ServerName = server;
    connectionInfo.Password = password;
    connectionInfo.UserID = user;
    

    EDIT: Looks like Nathan beat me to it, as mine is from the same page.

    EDIT AGAIN: I should note that ConnectionInfo is in the CrystalDecisions.Shared namespace. As for how to get it from a generic DB connection, I'm not sure.

提交回复
热议问题