Saturday, September 27, 2008

Why I got NullReferenceException when using DataView.AddNew()?

Code:
DataView dv = new DataView();
DataRowView drv = dv.AddNew(); // throw NullReferenceException

Reason:
If you create a DataView using the constructor that does not take any arguments, you will not be able to use the DataView until you have set the Table property.
http://msdn.microsoft.com/en-us/library/hy5b8exc(VS.71).aspx

No comments: