Table: Cliente
Adapter:ClientesTableAdapter
My ClientesTableAdapter SelectCommand have the next Code:
CommandText=SELECT ApellidoPat, ApellidoMat, Nombres, Telefono, TelCel, RFC, CURP, NoSeguro
FROM Clientes
WHERE (Nombre LIKE @PNombres)
CommadType=Text
Till here everything is ok, but Now i need to retrieve the data from a ButtonClick event here is my code:
Firts of all here is My Previus Function string connection:
ConexionGeneral ConexionBd = new ConexionGeneral(); <
private void Button1_Click(object sender, EventArgs e)
{
DsMainFactuExpressTableAdapters.ClientesTableAdapter TClientes = new DsMainFactuExpressTableAdapters.ClientesTableAdapter();
TClientes.Connection.ConnectionString = ConexionBd.RutaConexionIniBD();
TClientes.Adapter.SelectCommand.Parameters.Add("@Nombre", "Hiber");
TClientes.Adapter.SelectCommand.ExecuteScalar();
TClientes.Fill(this.DsClientes.Clientes);
}
When i click appears this exception:
TClientes.Adapter.SelectCommand.Parameters.Add("@Nombre", "Hiber"); <<<<<<< Use the new Keyword to create a object instance
So My Question is how can i create a new instance?
or How can i get to my parameter to filter my table?
I'm Using Firebird Database and VS C# 2008, i'm new in C# i come from Delphi
Thank you.
Sam HobbsPosted Nov 14, 2010, 5:29 PM
Hiber Tadeo Moreno TovillaPosted Nov 14, 2010, 1:47 PM
this.ClientesTableAdapter.FillByClientesNombres(this.ClientesDataSet.Clientes,EdtParam.Text);
Thank Ya.
Sam HobbsPosted Nov 11, 2010, 2:17 AM
When I use a TableAdapter to process a table in some other manner, I usually create it as a member of a form; I do not create it as an object local to a function.
Also, for TableAdapters the parameters are usually specified in the3 configuration of the TableAdapter. Are you sure you must alter the select statement for the TableAdapter? You can specify parameters in the TableAdapter and that would make what you are doing much simpler.