Click here to Skip to main content
15,900,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i just want to ask how to code in C# using sql server the following scenario:

1. I am coding a page that reflects if a form is already submitted or not. i have [name] column and [date submitted] column.

2. I want to replace the data inside the [date submitted] column. I want to reflect it as ALREADY SUBMITTED if [date submitted] has entry and NOT YET SUBMITTED if [date submitted] is null.

3. [name] and [date submitted] comes from different databases: mydb.name and project.dateSubmitted

4. it will reflect into just one gridview

5. inside gridview, there will be a column for buttons. if [date submitted] is null, the button will be disabled. enabled if [date submitted] has entry.

thanks
Posted
Comments
Maciej Los 12-Aug-13 1:56am    
And what is the exact question?

Try
//dr is datareader
if ( dr[0][0] is DBNull )
{
//Handle null here
}
 
Share this answer
 
Comments
Maciej Los 12-Aug-13 2:05am    
A5!
Abhinav S 12-Aug-13 2:10am    
Thanks
The best way to handle this is get the required result from the database. The query would be like the one below:

SQL
SELECT NAME,
CASE WHEN dateSubmitted IS NULL THEN 'NOT YET SUBMITTED'
     ELSE 'ALREADY SUBMITTED' END 'STATUS'
FROM MYTABLE
 
Share this answer
 
Comments
Maciej Los 12-Aug-13 2:05am    
Good answer, +5!
macmacmacmac 12-Aug-13 2:08am    
nice answer, +5. now, i want it to feed inside a gridview that has a column for button. if dateSubmitted is null, the buttons will be disabled. enabled if has entry.

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