FrmBaseDatos, FrmDatos y FrmProcedimientos: Botón refrescar
This commit is contained in:
@@ -6,19 +6,28 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using ServerExplorer.Code;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace ServerExplorer.UI
|
||||
{
|
||||
public partial class FrmDatos : Form
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private TablaDesc tablaDesc = null;
|
||||
private string conexionString = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Form life cycle
|
||||
|
||||
public FrmDatos(DataTable dt, String titulo)
|
||||
public FrmDatos(TablaDesc tablaDesc, string conexionString)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Text = titulo;
|
||||
dgvDatos.DataSource = dt;
|
||||
this.tablaDesc = tablaDesc;
|
||||
this.conexionString = conexionString;
|
||||
LoadDataFromTable();
|
||||
}
|
||||
|
||||
private void frmDatos_Load(object sender, EventArgs e) { }
|
||||
@@ -40,6 +49,28 @@ namespace ServerExplorer.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void btnRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadDataFromTable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void LoadDataFromTable()
|
||||
{
|
||||
Text = tablaDesc.Esquema + "." + tablaDesc.Nombre;
|
||||
string tableFullName = "[" + tablaDesc.Esquema + "].[" + tablaDesc.Nombre + "]";
|
||||
DataTable dt= new DataTable();
|
||||
SqlConnection cnx = new SqlConnection(conexionString);
|
||||
SqlDataAdapter da = new SqlDataAdapter( "select * from " + tableFullName, cnx);
|
||||
cnx.Open();
|
||||
da.Fill(dt);
|
||||
cnx.Close();
|
||||
dgvDatos.DataSource = dt;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user