0
private void button1_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection(conString);
    con.Open();
    if (con.State == System.Data.ConnectionState.Open)
    {


        SqlCommand cmd = new SqlCommand("select * from Employee_Details where email = '"+txtEmail.Text+"' and password = '"+txtPass.Text+"'", con);

        SqlDataReader dr; 
        dr = cmd.ExecuteReader();

        int count = 0;
        while(dr.Read())
        {
            count += 1;
        }

        if (count == 1)
        {
            con.Close();
            con.Open();


            SqlCommand cmd_user = new SqlCommand("select id from Employee_Details where email = '" + txtEmail.Text + "' and password = '" + txtPass.Text + "'", con);

            SqlDataReader reader = cmd_user.ExecuteReader();

            while (reader.Read())
            {

                string user_id = Convert.ToString(reader["id"]);

            }

            MessageBox.Show("Log in Successfull");
            this.Hide();
            MainMenu mn = new MainMenu();
            mn.ShowDialog();


        }

I store the variable here:

I store the variable here

Actually, I store the data in a variable (string user_id) that came from database.Now I want to use this variable to another form. When I take the variable from the first form, I got a null value.

Rafayet
  • 35
  • 4

0 Answers0