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 HobbsRank #108 · 20.5K reputationPosted Nov 10, 2010, 9:17 PM EST
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.
Hiber Tadeo Moreno Tovilla61 reputationPosted Nov 14, 2010, 8:47 AM EST
this.ClientesTableAdapter.FillByClientesNombres(this.ClientesDataSet.Clientes,EdtParam.Text);
Thank Ya.
Sam HobbsRank #108 · 20.5K reputationPosted Nov 14, 2010, 12:29 PM EST