0

Hello
Dear Friends,
I need some help to check avilidity of the username on Leave event of a textbox in Database SQL Server, but i cann't get.
it code is bellow

private void textBox6_Leave(object sender, EventArgs e)
        {
            cmd = new SqlCommand("SELECT * FROM usertab WHERE username='"+textBox6.text+"'",con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(ds);
            int i = ds.Tables[0].Rows.Count;
            if (i > 0)
            {
                label21.Text = "username is already exists";
                ds.Clear();
            }
            else
            {

                label21.Text = "username is available";
            }

        }

con Connetion and DataSet=ds are defined in public section.

SqlConnection con = new SqlConnection("data source=MUHAMMAD\\SQLEXPRESS; database = MMS; integrated security = SSPI");
DataSet ds = new DataSet();
2
Contributors
1
Reply
23
Views
2 Weeks
Discussion Span
Last Post by Andy_12
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.