With the procedure from -
http://msdn.microsoft.com/en-us/library/bb669096%28v=vs.110%29.aspx and some great help at DNF, I could make it to this point.
But, I get the following error, at the CopyToDataTable method.
ArgumentNullException
Value cannot be null.
Parameter name: source
Where am I going wrong.
public DataTable GetAllRecords()
{
try
{
DataTable dt = new DataTable();
IEnumerable<DataRow> query = ((from p in MedianDB.tblCountries
select p).OrderBy(p => p.CountryName)) as IEnumerable<DataRow>;
query.CopyToDataTable<DataRow>(dt,LoadOption.PreserveChanges);
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
Using .Net Framework 4.0,C#,Linq
Thank you.