{
if (cbmFiltrar.Text == "Código")
{
//Define a instrução Sql
string sql = "SELECT * FROM tbCliente WHERE codFuncionario =" + txtPesquisar.Text + "";
//Lê os dados da variavel sql e conectar no cn
cmd = new SqlCommand(sql, cn);
//Abre conexão
cn.Open();
//Define o valor da CommandType para cmd
cmd.CommandType = CommandType.Text;
/*Representa um conjunto de comandos de dados e uma conexão de banco de dados
* que são usados para preencher o DataSet e atualizar um banco de dados SQL Server.*/
SqlDataAdapter da = new SqlDataAdapter(cmd);
//Representa uma tabela de dados na memória.
DataTable cliente = new DataTable();
/* Adiciona ou atualiza linhas em um DataTable para que correspondam na fonte de
* dados usando o DataTable.*/
da.Fill(cliente);
/*A tbClienteDataGridView recebe o DataTable cliente*/
tbClienteDataGridView.DataSource = cliente;
//Fechar a conexão
}
if (cbmFiltrar.Text == "Nome")
{
//define a instrução SQL
string sql = "SELECT * FROM tbCliente WHERE cliente LIKE '%" + txtPesquisar.Text + "%'";
cmd = new SqlCommand(sql, cn);
cn.Open();
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable cliente = new DataTable();
da.Fill(cliente);
tbClienteDataGridView.DataSource = cliente;
}
if (cbmFiltrar.Text == "CPF")
{
//define a instrução SQL
string sql = "SELECT * FROM tbCliente WHERE CPF ='" + txtPesquisar.Text + "'";
cmd = new SqlCommand(sql, cn);
cn.Open();
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable cliente = new DataTable();
da.Fill(cliente);
tbClienteDataGridView.DataSource = cliente;
}
if (cbmFiltrar.Text == "")
{
//define a instrução SQL
string sql = "SELECT * FROM tbCliente";
cmd = new SqlCommand(sql, cn);
cn.Open();
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable cliente = new DataTable();
da.Fill(cliente);
tbClienteDataGridView.DataSource = cliente;
}
}
catch (Exception ex)
{
//Caso haja uma exceção
MessageBox.Show(ex.Message);
}
finally
{
//Fechar a conexão
cn.Close();
}
quarta-feira, 28 de setembro de 2011
Ot Pokemon
| Principal |
| Aprenda a Jogar |
| Criar Account |
| Download Cliente |
| Ranking |
| Desbugar Char |





RightLeft
Perdeu sua account? Click aqui!
otPokémon.com BRASIL fãSite © 2011
© 1995-2010 Nintendo/Creatures Inc./GAME FREAK inc. Pokémon and Pokémon character names are trademarks of Nintendo.
+Sua Account
Aprenda a Jogar
Download Cliente 3.0
Mapa OTP
Casas
Guilds
Ranking
Regras
Videos
Players Online
Personagens
Ultimas Mortes
+VIP Shop
+Fazer Doação
Aprenda a Jogar
Download Cliente 3.0
Mapa OTP
Casas
Guilds
Ranking
Regras
Videos
Players Online
Personagens
Ultimas Mortes
+VIP Shop
+Fazer Doação
Status: Online
Players: 435
Uptime: 6h 51m
Status: Online
Players: 342
Uptime: 13h 48m
Status: Online
Players: 173
Uptime: 0h 7m
Assinar:
Postagens (Atom)