This project is read-only.

Null Value exception

Mar 29, 2008 at 5:49 AM
When I access a sharepoint list field with a null value (no entry), I get an exception error.

I have suucessully connected to the list and I am trying to populate a SQL Server Compact Edition (sdf) database. When I interate throuhg the query, if a filed has null value, it gives me an error and I had to work around using try / catch exception. I am sure there is a better way and I am missing something.

HEre is a portion of the code:

string conn ="|DataDirectory|\\Schedule.sdf";
DataContext ds = new DataContext(conn);
Table<ScheduleData> Schedules = ds.GetTable<ScheduleData>();
Table<Rooms> Rms = ds.GetTable<Rooms>();
Table<Resources> Rsc = ds.GetTable<Resources>();

var ct = new ScheduleDataSharePointDataContext();
var dt = from p in ct.MTCEngagements
where p.StartDate12 > DateTime.Today.AddDays(-1)
orderby p.StartDate12
select p;
//ct.Log = Console.Out;
//ds.Log = Console.Out;

foreach (var q in dt)

string lead= null;
lead = q.Lead.ResourceAlias; // I get an error if the Lead.ResourceAlias is null.......

catch (Exception)
lead = "None";