I am working on a database project using Microsoft Visual Studio 2013, and also Microsoft SQL Server 2014 respectively. I have about four tables in my project named UsersDataSet. I want to create filter controls for each form application using combo boxes and textboxes. I want to use the UsersRegister form as an example.
In the loginDataSet filter column I configured the SQL query;
"SELECT Username, Password, Role
FROM Login
WHERE (Username = @username)"
Likewise;
SELECT Username, Password, Role
FROM Login
WHERE (Role = @Role)
Then in the code window;
But when I run the application and try to filter for any record, only the first row is filtered; unless I place the cursor on a specific username or role before it can be filtered. I don't know where the error is. This error occurs to all the other applications in the project.
Please I would appreciate if someone can help me fix it.
Thanks.
Godis
In the loginDataSet filter column I configured the SQL query;
"SELECT Username, Password, Role
FROM Login
WHERE (Username = @username)"
Likewise;
SELECT Username, Password, Role
FROM Login
WHERE (Role = @Role)
Then in the code window;
C#:
private void txtSearch_KeyUp(object sender, KeyEventArgs e)
{
if(txtSearch.Text == "")
{
this.loginTableAdapter.Fill(this.usersDataSet.Login);
}
else if(combSearch.SelectedIndex == 0)
{
this.loginTableAdapter.FillByUsername(this.usersDataSet.Login, usernameTextBox.Text);
}
else if(combSearch.SelectedIndex == 1)
{
this.loginTableAdapter.FillByRole(this.usersDataSet.Login, combRole.Text);
}
}
But when I run the application and try to filter for any record, only the first row is filtered; unless I place the cursor on a specific username or role before it can be filtered. I don't know where the error is. This error occurs to all the other applications in the project.
Please I would appreciate if someone can help me fix it.
Thanks.
Godis
Last edited: