P
Peter
I am trying to identify which field in Access database table is an
Auto_Incement field, here's the code I am using, but I do not know how to
tell if the field is Auto_Increment type of field. Does anyone has a way to
do that?
Thank You
Peter
DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[] { null, null, tableName });
DataRow row;
for (int i = 0; i < schemaTable.Rows.Count; i++)
{
col = new Column();
row = schemaTable.Rows;
col.Name = row["COLUMN_NAME"].ToString();
int FlagsPos = schemaTable.Columns.IndexOf("COLUMN_FLAGS");
int Flags = Convert.ToInt32(row.ItemArray[FlagsPos]);
col.Type = Convert.ToInt32(row["DATA_TYPE"]);
col.OrdinalPosition = Convert.ToInt32(row["ORDINAL_POSITION"]);
//
// this does not work, it identifies any numeric field as 3 and Flags =
90
//
if(col.Type == 3 && Flags == 90)
col.AutoIncrement = true;
columns.Add(col);
}
Auto_Incement field, here's the code I am using, but I do not know how to
tell if the field is Auto_Increment type of field. Does anyone has a way to
do that?
Thank You
Peter
DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[] { null, null, tableName });
DataRow row;
for (int i = 0; i < schemaTable.Rows.Count; i++)
{
col = new Column();
row = schemaTable.Rows;
col.Name = row["COLUMN_NAME"].ToString();
int FlagsPos = schemaTable.Columns.IndexOf("COLUMN_FLAGS");
int Flags = Convert.ToInt32(row.ItemArray[FlagsPos]);
col.Type = Convert.ToInt32(row["DATA_TYPE"]);
col.OrdinalPosition = Convert.ToInt32(row["ORDINAL_POSITION"]);
//
// this does not work, it identifies any numeric field as 3 and Flags =
90
//
if(col.Type == 3 && Flags == 90)
col.AutoIncrement = true;
columns.Add(col);
}