Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error on Coding

Error on Coding

Scheduled Pinned Locked Moved C#
databasemysqlhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    N Mohamed rafi
    wrote on last edited by
    #1

    Error:

    the name cmd does not exist in current context

    if(textBox9.Text!="" && textBox10.Text!= "")
    {
    string connectionString;
    MySqlConnection cnn;
    connectionString = @"Data Source=localhost;Initial Catalog=testDB;User ID=root;Password=mysql";
    cnn = new MySqlConnection(connectionString);
    string id = textBox9.Text;
    string password = textBox10.Text;
    textBox9.Text = "";
    textBox10.Text = "";
    string query = "select count (*) from login where userid='" + textBox9.Text + "' and password='" + textBox10.Text + "'";
    int count = Convert.ToInt32(cmd.ExecuteScalar());
    using (MySqlCommand cmd = new MySqlCommand(query))
    if (count >= 1)
    {
    cmd.Parameters.AddWithValue("@userid", id);
    cmd.Parameters.AddWithValue("@password", password);
    cmd.Connection = cnn;
    cnn.Open();
    cmd.ExecuteNonQuery();
    MessageBox.Show("Login Successfully");
    cnn.Close();
    this.Hide();
    Form2 f2 = new Form2();
    f2.ShowDialog();
    }
    else
    {
    MessageBox.Show("Please Enter Correct Login details");
    }

            }
            else
            {
                MessageBox.Show("Please Enter Details to Login");
            }
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups