I have two tables Activities and Sources. I want to check if IdSource from Sources, which is primary key, is found in the column Sources from table Activities. I did something like
private int nrSource {get;set;}
nrSource=(int)activitiesTableAdapter.ScalarQuery();
if (nrSource>0)
{
MessageBox.Show();
}
And the ScalarQuery method is something like select count (*) from Activities where exists (select * from Sources where Sources.IdSource=Activities.Sources).
I get an error where I make the cast: Object reference not set to an instance of an object. What am I doing wrong?