4
Answers

compare the database

Krishna

Krishna

9y
630
1
i had a code in which text box 2 accepts the two strings and i would like to compare them with the database i had done the code to split the text box 2 sting into multiple and stored in
myarray 


SqlCommand cmd = new SqlCommand("insert  comparative values('" + TextBox1.Text + "','" + TextBox2.Text + "')", con);
        string[] myArray = TextBox2.Text.Split(new Char[] { '&' });

        cmd.ExecuteNonQuery();
        cmd.Connection = con;
        cmd.CommandText = "select * from places where names = @myArray ";


        cmd.Parameters.AddWithValue("@myArray", myArray.ToString());


        SqlDataReader sdr = cmd.ExecuteReader();

        if (sdr.Read())
        {

            Label4.Text = TextBox2.Text;
        }
        else
        {
            Label4.Text = "Not Found";
        }

        con.Close();
           
     
        con.Close();
           
Answers (4)