i wrote this :
- MySqlConnection con = new MySqlConnection(connectionString);
- i = 0;
- con.Open();
- MySqlCommand cmd = con.CreateCommand();
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = "select * from informat where u_ser = '" + metroTextBox2.Text + "' ";
- cmd.ExecuteNonQuery();
- DataTable dt = new DataTable();
- MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- da.Fill(dt);
- i = dt.Rows.Count;
- int userial = metroTextBox2.Text.Length;
- if (userial >= 5 || metroTextBox2.Text == null)
- {
- MySqlConnection conet = new MySqlConnection(connectionString);
- conet.Open();
- MySqlCommand cmsd = conet.CreateCommand();
- cmsd.CommandType = CommandType.Text;
- cmsd.CommandText = "select * from alred where u_ser = '" + metroTextBox2.Text + "'and u_ip = '" + textBox1.Text + "'";
- cmsd.ExecuteNonQuery();
- DataTable ddts = new DataTable();
- MySqlDataAdapter ddas = new MySqlDataAdapter(cmsd);
- ddas.Fill(ddts);
- if (textBox1.Text != null)
- {
- MessageBox.Show("Your Serial is used in another computer");
- this.Close();
- }
- else if (metroTextBox2.Text == null & textBox1.Text == null)
- {
- ireview frms = new ireview();
- this.Hide();
- frms.Show();
- }
- else if (metroTextBox2.Text != null && textBox1.Text != null)
- {
- MySqlConnection conect = new MySqlConnection(connectionString);
- conect.Open();
- MySqlCommand cmsdd = conet.CreateCommand();
- cmsdd.CommandType = CommandType.Text;
- cmsdd.CommandText = "INSERT INTO alred (u_ser, u_ip) " + " Values ('" + metroTextBox2.Text + "', '" + textBox1.Text + "')";
- cmsdd.ExecuteNonQuery();
- DataTable sddts = new DataTable();
- MySqlDataAdapter sddas = new MySqlDataAdapter(cmsdd);
- sddas.Fill(sddts);
- ireview frms = new ireview();
- this.Hide();
- frms.Show();
- }
- }
- else
- {
- MessageBox.Show("You Serial Doesn't Exist");
- }
- }
but it doesn't work its always go directly to insert and it insert it two times
Puneet KankarPosted Jul 18, 2017, 2:19 PM
Puneet KankarPosted Jul 18, 2017, 8:24 PM
Ilyas ZahirPosted Jul 18, 2017, 4:07 PM