On my main form I have queried the user id on submission. Once I save the id to a variable how can I call it on another windows form in the same application?
This is what I have so far
private void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.database.windows.net;Initial Catalog=userlogins;Persist Security Info=True;User ID=****;Password=****");
SqlDataAdapter sda = new SqlDataAdapter("Select ID from users where username='" + txtUsername.Text + "' and password='" + txtPassword.Text + "' ", con);
SqlCommand cmd = con.CreateCommand();
con.Open();
// save SQL ID to variable
cmd.CommandText = "Select Id from users where username = '" + txtUsername.Text + "'";
int sqlid = ((int)cmd.ExecuteScalar());
Any information would be appreciated, I really need the ID on multiple other pages!