Thisbuttonisonlyanalternative,itshouldgothroughalltheBDrecordssincethefirstSEthetextboxisnotfilled;ifitisalreadyfilled,itmustgothroughallrecordsthatcontaintheNAMEsimilartotyped.
ItriedtousetheReader.NextResult()
optionbutwithoutsuccess.
HowdoIproceed?
FollowtheSearchbutton(magnifyingglass):
privatevoidbutton1_Click(objectsender,EventArgse){//DeclarasintrgdeconexãocomBDOleDbConnectionConnection=newOleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\xxxxx.accdb");
//Abrir conexão com BD
Connection.Open();
//Declarar Comando SQL
OleDbCommand Command = Connection.CreateCommand();
Command.CommandText = "SELECT * FROM tb_YYYY WHERE Nome LIKE '%" + txtUserOUNome.Text + "%'";
//Declarar DataReader
OleDbDataReader Reader = Command.ExecuteReader();
while (Reader.Read())
{
txtPesqNome.Text = Convert.ToString(Reader["Nome"]);
txtPesqUsuario.Text = Convert.ToString(Reader["Usuario"]);
txtPesqMail.Text = Convert.ToString(Reader["Mail"]);
}
//Fechar Reader e Conexão
Reader.Close();
Connection.Close();
}