I am using these lines of code to check if the record exists or not.
SqlCommand check_User_Name = new SqlCommand(\"SELECT * FROM Table WHERE ([user] = \'\" +
You can write as follows:
SqlCommand check_User_Name = new SqlCommand("SELECT * FROM Table WHERE ([user] = '" + txtBox_UserName.Text + "') ", conn); if (check_User_Name.ExecuteScalar()!=null) { int UserExist = (int)check_User_Name.ExecuteScalar(); if (UserExist > 0) { //Username Exist } }