Limpieza usando recomendaciones de R#
This commit is contained in:
@@ -9,7 +9,7 @@ namespace ServerExplorer.UI
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private SqlConnection cnx;
|
||||
private readonly SqlConnection _cnx;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace ServerExplorer.UI
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
cnx = new SqlConnection(cnxString);
|
||||
_cnx = new SqlConnection(cnxString);
|
||||
}
|
||||
|
||||
private void frmProcedimientos_Load(object sender, EventArgs e)
|
||||
@@ -35,9 +35,8 @@ namespace ServerExplorer.UI
|
||||
{
|
||||
if (lsvProcs.SelectedItems.Count <= 0) { return; }
|
||||
|
||||
string schema, name;
|
||||
name = lsvProcs.SelectedItems[0].SubItems[0].Text;
|
||||
schema = lsvProcs.SelectedItems[0].SubItems[1].Text;
|
||||
string name = lsvProcs.SelectedItems[0].SubItems[0].Text;
|
||||
string schema = lsvProcs.SelectedItems[0].SubItems[1].Text;
|
||||
LoadProcedure(schema, name);
|
||||
}
|
||||
|
||||
@@ -52,17 +51,14 @@ namespace ServerExplorer.UI
|
||||
|
||||
private void LoadProcedures()
|
||||
{
|
||||
DataTable dt;
|
||||
SqlDataAdapter da;
|
||||
|
||||
// Obtener un datatable con todos los procedimientos de la base de datos.
|
||||
da = new SqlDataAdapter(
|
||||
var da = new SqlDataAdapter(
|
||||
"SELECT ROUTINE_NAME Name, ROUTINE_SCHEMA [Schema], CREATED CreateDate, ROUTINE_TYPE [Type] FROM INFORMATION_SCHEMA.ROUTINES",
|
||||
cnx);
|
||||
dt = new DataTable();
|
||||
cnx.Open();
|
||||
_cnx);
|
||||
var dt = new DataTable();
|
||||
_cnx.Open();
|
||||
da.Fill(dt);
|
||||
cnx.Close();
|
||||
_cnx.Close();
|
||||
|
||||
// Mostrar todos los procedimientos
|
||||
lsvProcs.Items.Clear();
|
||||
@@ -87,14 +83,14 @@ namespace ServerExplorer.UI
|
||||
(sp.type = N'P' OR sp.type = N'RF' OR sp.type='PC')
|
||||
and
|
||||
(sp.name=@name and SCHEMA_NAME(sp.schema_id)=@schema)
|
||||
", cnx);
|
||||
", _cnx);
|
||||
|
||||
da.SelectCommand.Parameters.AddWithValue("@Name", name);
|
||||
da.SelectCommand.Parameters.AddWithValue("@Schema", schema);
|
||||
var dt = new DataTable();
|
||||
cnx.Open();
|
||||
_cnx.Open();
|
||||
da.Fill(dt);
|
||||
cnx.Close();
|
||||
_cnx.Close();
|
||||
|
||||
// Mostrar el contenido del procedimiento
|
||||
txtProc.Text = String.Empty;
|
||||
|
||||
Reference in New Issue
Block a user