I'm trying to figure out how to get my user data from the user I login with. I know how to get all the data to a gridview but not how to get the specific data for the user that are logged into my program.
This is how I login if that can be to any use
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=(local);Initial Catalog=MyDb;Integrated Security=True";
con.Open();
string txtUs = TxtUser.Text;
string txtPas = TxtPass.Text;
string query = "SELECT * FROM User WHERE Username=@user and Password =@pass";
SqlCommand cmd = new SqlCommand(query,con);
cmd.Parameters.Add(new SqlParameter("@user",txtUs));
cmd.Parameters.Add(new SqlParameter("@pass",txtPas));
SqlDataReader dr = cmd.ExecuteReader();
int count = 0;
while (dr.Read())
{
count = +1;
}
if (count == 1)
{
this.Hide();
var main = new Main();
main.Closed += (s, args) => this.Close();
main.Show();
}