Click here to Skip to main content
15,938,446 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 12-Aug-18 6:08am

1 solution

 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900