Q
Problem solve Get help with specific problems with your technologies, process and projects.

Getting field size and Allow Null property of a table in MS Access and SQL database?

How can I get a field's size and Allow Null property of a table in MS Access and SQL database?
First you need to retrieve the table schema from the database. Read this answer for instructions on how to do that. Once you have the structure, the DataTable object exposes all the available columns in it, and each column object exposes all the properties you may need, such as AllowDBNull, AutoIncrement, DefaultValue, etc. You can access a specific column by name or ordinal:
DataTable dt = ds.Tables["Customers"]; 
bool nulls = dt.Columns["id"].AllowDBNull;

This was last published in December 2003

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close