F
F.oliveirarocha
Guest
Hi folks, I need a help from the especialists.
The DataGridView is not populating with the ID desired in the textBox1, instead it is populating with the first ID's table.
It doesn't get currentId, it goes for the first row of the table.
I need that shows the selection of the record, populating the grid, which will be only one line.
I'm selecting a record to Update. That's it.
Here follows the code:
Thank you very much for your help.
private void btn_filtrar_Click(object sender, EventArgs e)
{
int numeroparcela = Convert.ToInt32(textBox1.Text);
this.numero_Parcelas_a_PagarTableAdapter.FillFiltroParcela(numeroParcelasaPagarUpdate.Numero_Parcelas_a_Pagar, numeroparcela);
string constr = @"Data Source=DESKTOP-3O98051;Initial Catalog=SGFRenaissance;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(constr))
data_VencimentoDateTimePicker.CustomFormat = null;
data_VencimentoDateTimePicker.Value.ToShortDateString();
{
try
{
conn.Open();
if (conn.State == ConnectionState.Open)
{
int currentId;
currentId = numeroparcela;
// int index = numero_Parcelas_a_PagarDataGridView.CurrentCell.RowIndex;
currentId = Convert.ToInt32(numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells["ID_Parcela"].Value);
var select = "Select * From Numero_Parcelas_a_Pagar Where Cod_Numero_Parcelas_a_Pagar= " + currentId; // This currentId gets the value"6" always.
SqlDataAdapter sda = new SqlDataAdapter(select, conn);
DataSet Ds = new DataSet();
sda.Fill(Ds, "T1");
numero_Parcelas_a_PagarDataGridView.DataSource = Ds.Tables["T1"];
}
else
{
MessageBox.Show("Falha na Abertura da Conexão ao Banco de Dados!", "Erro!");
}
}
catch (Exception Ex)
{
MessageBox.Show("Falha na Leitura dos Dados na Tabela! " + Ex.Message);
}
finally
{
conn.Close();
}
}
}
I don't get any error message. It works, but getting the first record of the table, not the value of the textBox1.
Is it Clear ?
Best Regards.
Continue reading...
The DataGridView is not populating with the ID desired in the textBox1, instead it is populating with the first ID's table.
It doesn't get currentId, it goes for the first row of the table.
I need that shows the selection of the record, populating the grid, which will be only one line.
I'm selecting a record to Update. That's it.
Here follows the code:
Thank you very much for your help.
private void btn_filtrar_Click(object sender, EventArgs e)
{
int numeroparcela = Convert.ToInt32(textBox1.Text);
this.numero_Parcelas_a_PagarTableAdapter.FillFiltroParcela(numeroParcelasaPagarUpdate.Numero_Parcelas_a_Pagar, numeroparcela);
string constr = @"Data Source=DESKTOP-3O98051;Initial Catalog=SGFRenaissance;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(constr))
data_VencimentoDateTimePicker.CustomFormat = null;
data_VencimentoDateTimePicker.Value.ToShortDateString();
{
try
{
conn.Open();
if (conn.State == ConnectionState.Open)
{
int currentId;
currentId = numeroparcela;
// int index = numero_Parcelas_a_PagarDataGridView.CurrentCell.RowIndex;
currentId = Convert.ToInt32(numero_Parcelas_a_PagarDataGridView.CurrentRow.Cells["ID_Parcela"].Value);
var select = "Select * From Numero_Parcelas_a_Pagar Where Cod_Numero_Parcelas_a_Pagar= " + currentId; // This currentId gets the value"6" always.
SqlDataAdapter sda = new SqlDataAdapter(select, conn);
DataSet Ds = new DataSet();
sda.Fill(Ds, "T1");
numero_Parcelas_a_PagarDataGridView.DataSource = Ds.Tables["T1"];
}
else
{
MessageBox.Show("Falha na Abertura da Conexão ao Banco de Dados!", "Erro!");
}
}
catch (Exception Ex)
{
MessageBox.Show("Falha na Leitura dos Dados na Tabela! " + Ex.Message);
}
finally
{
conn.Close();
}
}
}
I don't get any error message. It works, but getting the first record of the table, not the value of the textBox1.
Is it Clear ?
Best Regards.
Continue reading...