How to discover required field

  • Thread starter Thread starter Konrad
  • Start date Start date
Not sure if I understand, but if you are looking to see if a field allows
nulls or not (if not, you have to put something in it), then this should
work. However, if you have a defaultvalue, then it can no allow nulls but
still not be required per se.



foreach( DataColumn dc in dt.Columns )
{
listBox1.Items.Add(dc.ColumnName+" , "+dc.DataType +" ,"+dc.Unique +"
,"+dc.AutoIncrement+" ,"+dc.AllowDBNull + ", " + dc.DefaultValue );
}

}



dc.AllowDBNull will be true if it's not required.
 
Thanks for the excellent answer, William!

Steven Bras, MCSD
Microsoft Developer Support/Data Access Technologies

This posting is provided "AS IS" with no warranties, and confers no rights.

Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-026?  If not Microsoft strongly advises you to
review the information at the following link regarding Microsoft Security
Bulletin MS03-026
http://www.microsoft.com/security/security_bulletins/ms03-026.asp and/or to
visit Windows Update at http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026.
 
Back
Top