0
First of all, I apologise if the question is vague, as it is a very broad subject.
Today I have a student registration and consultation system, where the query is made exclusively by CPF, since it is a unique identifier and a Constraint in the database will assure me that there will be no repeated CPF, thus returning only one result in the query.
The query in the database is done via dataset, by an Auxiliadora class that we have. The method is basically this:
CeltaWare.Data.SqlHelper.FillDataset(
sqlConn,
CommandType.Text,
"SELECT * FROM ALUNOS WHERE CPF = @CPF",
dataSet,
new string[] { "Alunos" },
new SqlParameter("@CPF", aluno.Cpf));
And if in the case, I want to search by name too?
Obviously, there may be several students with the same first name, and then the app should return a list to select the student we want.
The question is: How should this list be created? Being a beginner in C#, I don’t have much idea how to do this. It would be a new Form, with Abels who would have the Text
replaced by our research?
Thank you in advance!
You didn’t report which one is yours front end, if Forms or Web, but how can it be more of a record, a kind grid can help (Gridview for example)
– Ricardo Pontual
Sorry, it’s Windowsforms
– Lucas Bustos
In that case you can use Datagridview, all documentation with examples you can see here: https://docs.microsoft.com/pt-br/dotnet/framework/winforms/controls/datagridview-control-overview-windows-forms
– Ricardo Pontual
@Lucasbustos the Datagridview would be the ideal opposition, more if you prefer to use a
List<Aluno>
: You have to create a Student Class list by feeding your properties with aforeach
going through all the columns of each row of your dataset. Put theClass Aluno
and the entire method used in the dataset to serve as the basis, which assembles a scheme from thedataset
you already have.– Paulo Ricardo