Click here to Skip to main content
13,833,837 members
Rate this:
Please Sign up or sign in to vote.
See more:
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...

What I have tried:


        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);

     if (readerHasRows == true)
            MessageBox.Show("This borrower has borrowed the book please collect the book first.");
Updated 12-Aug-18 7:08am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

hassanjaved110 12-Aug-18 12:10pm
i got rows, but i need just if empty column book1 or book2 then i need value false if book1 or book2 not null so i need value false in readerhasrows
Richard MacCutchan 12-Aug-18 12:43pm
Then you need to use your debugger to see exactly what is being returned from your query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190114.1 | Last Updated 12 Aug 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100