I have an Access 2013 database and I'm trying to connect to it in C# and get information about the fields in the database. Everything is working except one thing I'm not sure about is how to determine if a field is a calculated field or not. Here is my Access database schema:
.---------------------------------------------------.
| TestTable1 |
|---------------------------------------------------|
| Field Name | Data Type | Comments |
|---------------------------------------------------|
| ID | AutoNumber| Primary Key |
| Field1ShortText | Short Text| |
| Field2LongText | Long Text | |
| Field3Calculated| Calculated| Formula = 1+2 |
.---------------------------------------------------.
Here is my C# code:
using (var connection = new OleDbConnection(ConnectionString))
{
connection.Open();
using (DataTable columns = connect.GetSchema("Columns"))
{
foreach (DataRow row in columns.Rows)
{
if (((string)row["TABLE_NAME"]).ToLower() != tableName.ToLower())
continue;
var field = new Field();
field.FieldName = (string) row["COLUMN_NAME"];
field.IsCalculated = ? // Here is where I'm stuck
}
}
}
I'm iterating through all the columns in my Access database and I am setting a property called IsCalculated
. This is a bool
property that should be either true
if its calculated or false
. I'm not sure how to determine this. There is a column returned from GetSchema
called COLUMN_FLAGS
, which probably has the information I need. However, I cannot seem to find any reference documentation on what these "flags" are.
Any help would be appreciated!