Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Display popup message if more than one row is empty in database table
====================================================================

Hi Experts !!

am working on ASP.NET, C#, SQLSERVER 2005.

on my webpage i have a Submit button, when i click this button it should check if More than one row is empty in database table..... TABLE NAME is (UserRecords).

If more than one row is empty it must display a message "please add the records".

Please help me how to do this

Thnks.........
Posted
Updated 15-May-13 9:09am
v2
Comments
Richard C Bishop 15-May-13 15:12pm    
You will have to query the database to determine if there are rows or not. If the method you read the data with returns some rows, then that is what the table contains. It is not like EXCEL where there are a million lines below the last row of data in the file. The table either has data in a row or no row exists.
R. Giskard Reventlov 15-May-13 18:58pm    
Why on earth would you have an empty row in a table??? Do you mean that you are trying to check if a user already exists before inserting a new user record?

1 solution

SQL
--Try this
SELECT Count(*) 
FROM   tbl_sample 
WHERE  name = 'srinu' 
GROUP  BY name 
HAVING Count(name) = 1 


By using the above query you will get only one row from the table.

use this and write code to display the popup message if there is no row coming from the database.
 
Share this answer
 
v3

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