DatabaseDA.GetInfo: Use conexion Database name when the query does not return any data.
This commit is contained in:
@@ -33,6 +33,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
|
||||
|
||||
public static Database GetInfo(string connectionString)
|
||||
{
|
||||
string databaseName = null;
|
||||
var cnx = new SqlConnection(connectionString);
|
||||
string strCmd = string.Format(@"
|
||||
SELECT
|
||||
@@ -44,9 +45,19 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
|
||||
var da = new SqlDataAdapter(strCmd, cnx);
|
||||
var dt = new DataTable();
|
||||
cnx.Open();
|
||||
databaseName = cnx.Database;
|
||||
da.Fill(dt);
|
||||
cnx.Close();
|
||||
|
||||
if(dt.Rows.Count == 0)
|
||||
{
|
||||
return new Database
|
||||
{
|
||||
Name = databaseName,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
};
|
||||
}
|
||||
|
||||
var database = new Database
|
||||
{
|
||||
Name = Convert.ToString(dt.Rows[0]["DatabaseName"]),
|
||||
|
||||
Reference in New Issue
Block a user