hassanjaved110 Ответов: 1

В C# типа bool количество строк с пустыми столбцами, каждый раз, правда


i have 2 columns book1 and book2 to in borrowes table but some time users borrowed the book and some time no, so i need to delete user which not borrowed any book (book1 or book2). but i got every time value in True... let me know what can i do thanks. i tried this...


Что я уже пробовал:

con.Open();

        bool readerHasRows = false;
        string brid = txtBr_id.Text;
        String syntax = "SELECT book1, book2 FROM Borrowes WHERE brId = @brid";
        using (SqlCommand cmd = new SqlCommand(syntax, con))
        {
            cmd.Parameters.AddWithValue("@brid", txtBr_id.Text);


            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                readerHasRows = (!reader[0].IsDBNull);
            }
        }
        con.Close();

     if (readerHasRows == true)
        {
            MessageBox.Show("This borrower has borrowed the book please collect the book first.");
        }

1 Ответов

Рейтинг:
0

hassanjaved110

у меня строк, но мне нужна просто пустая колонка книга1 или book2 тогда мне нужно значение false, если книга1 или book2 не равен null, поэтому мне нужно значение false в readerhasrows

Richard MacCutchan

Затем вам нужно использовать свой отладчик, чтобы точно увидеть, что возвращается из вашего запроса.