Quantcast
Channel: SQL Server Compact Forum
Viewing all articles
Browse latest Browse all 193

How to handle null value from SqlCe

$
0
0

I have a table which contains many fields; there are 2 fields of string type GpsLat and GpsLon.

I am not sure how to handle the null type in SqlCe Database.

after a select-statement using LinQToSQL , I use foreach to handle the items.

I have these questions:

1) If no data enter for fields GpsLat and GpsLon. 
    What will be the value? Null or empty ?  can  I use  string strGpsLat = c.GpsLat?

2) If no data enter for fields GpsLat and GpsLon, What will happen in CalculateDistance() ?
    can Convert.ToDouble() handle null and empty ?

 Thanks.

foreach (var c in Cat)
    {
                          
       double KM = CalculateDistance(g_strFromLat, g_strFromLon, c.GpsLat, c.GpsLon);

                             
 }

 private double CalculateDistance(string StartLat1, string StartLon1, string Lat2, string Lon2)
       {

         GeoCoordinate start = new GeoCoordinate(Convert.ToDouble(StartLat1), Convert.ToDouble(StartLon1));
           GeoCoordinate end = new GeoCoordinate(Convert.ToDouble(Lat2), Convert.ToDouble(Lon2));

           double distance = start.GetDistanceTo(end);        
           double DistanceInKM = Math.Round((distance * 0.001), 2);      

           return DistanceInKM;        

       }


Viewing all articles
Browse latest Browse all 193

Trending Articles