|
-
Jun 14th, 2005, 01:46 PM
#1
Thread Starter
Hyperactive Member
C# newbie questions
Hi!
I am a newbie on c#.
I have two simple questions:
a) How to print current date and time on my web page. Do I need to include any namespace for it.
b) How to check for null values. I create a dataset. For each item of the rows, I want to perform a nukk checking.
-
Jun 14th, 2005, 04:07 PM
#2
Re: C# newbie questions
use DateTime.Now
you can call the .ToShortDateString(), the .ToLongDateString(), or the .ToString() method of that class. ToString would let you customize the way the date is formatted. If you use ToString then you can look up here on MSDN on the formatting strings you can use http://msdn.microsoft.com/library/en...asp?frame=true
I dunno about datasets, but in general if (item == null) // do something;
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jun 14th, 2005, 06:15 PM
#3
Re: C# newbie questions
Although I've developed in C# I've only ever actually tried what you're asking in VB. I think the correct C# syntax is:
if (myDataRow["fieldname"].GetType() == typeof(DBNull))
or also:
if (myDataRow["fieldname"] == DBNull.Value)
-
Jun 14th, 2005, 08:59 PM
#4
Re: C# newbie questions
or you can do a loop to your dataset
Code:
foreach(Datarow dr in mydataset.tables[0].rows){
if(dr[0].tostring=="")<---indicates 1st column
{
//do your job
}
}
-
Jun 14th, 2005, 09:30 PM
#5
Re: C# newbie questions
 Originally Posted by mar_zim
or you can do a loop to your dataset
Code:
foreach(Datarow dr in mydataset.tables[0].rows){
if(dr[0].tostring=="")<---indicates 1st column
{
//do your job
}
}
What if the field contains an empty string? That's not a null value but will still return true in this case.
-
Jun 14th, 2005, 09:50 PM
#6
Re: C# newbie questions
ouchh. sorry im asumming it won't contain empty string. coz usually if i check a null value i used "".
this one will work. if (myDataRow["fieldname"] == DBNull.Value)
-
Jun 15th, 2005, 07:17 AM
#7
Thread Starter
Hyperactive Member
Re: C# newbie questions
Thanks a bunch ..........
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|