Click here to Skip to main content
13,665,440 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:

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.");
        }
Posted 12-Aug-18 6:01am
Updated 12-Aug-18 6:08am

1 solution

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

Solution 1

  Permalink  
Comments
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
Web01-2016 | 2.8.180810.1 | Last Updated 12 Aug 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

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