How to code a new sqlcode or get inside a TableAdapter?

Nov 11 2010 12:33 AM
Hi all, i need to get a new SQL code inside a Tabla adapter, my Table and the  adapter are  inside of a  DataSet named=DsMainFactuExpress, example:

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(); <<This come from another Class

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.

Answers (3)