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)
|
public static Database GetInfo(string connectionString)
|
||||||
{
|
{
|
||||||
|
string databaseName = null;
|
||||||
var cnx = new SqlConnection(connectionString);
|
var cnx = new SqlConnection(connectionString);
|
||||||
string strCmd = string.Format(@"
|
string strCmd = string.Format(@"
|
||||||
SELECT
|
SELECT
|
||||||
@@ -44,9 +45,19 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
|
|||||||
var da = new SqlDataAdapter(strCmd, cnx);
|
var da = new SqlDataAdapter(strCmd, cnx);
|
||||||
var dt = new DataTable();
|
var dt = new DataTable();
|
||||||
cnx.Open();
|
cnx.Open();
|
||||||
|
databaseName = cnx.Database;
|
||||||
da.Fill(dt);
|
da.Fill(dt);
|
||||||
cnx.Close();
|
cnx.Close();
|
||||||
|
|
||||||
|
if(dt.Rows.Count == 0)
|
||||||
|
{
|
||||||
|
return new Database
|
||||||
|
{
|
||||||
|
Name = databaseName,
|
||||||
|
CreateDate = DateTime.UtcNow,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var database = new Database
|
var database = new Database
|
||||||
{
|
{
|
||||||
Name = Convert.ToString(dt.Rows[0]["DatabaseName"]),
|
Name = Convert.ToString(dt.Rows[0]["DatabaseName"]),
|
||||||
|
|||||||
Reference in New Issue
Block a user