Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:26:48+00:00 2026-05-30T11:26:48+00:00

I need my program check if specified column exists in MS Access 2000 database,

  • 0

I need my program check if specified column exists in MS Access 2000 database, and if it doesn’t – add it. I use .NET Framework 2.0
I tried to use oleDbConnection.GetSchema() method, but couldn’t find column names in metadata (i’m really not a pro, huh) and any specification on msdn.
I would appreciate any help.

Thanks for answers.
Here is solution i used in my code:

bool flag = false; string[] restrictions = new string[] { null, null, mytable };
DataTable dtColumns = oleDbConnection1.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, restrictions);
foreach (DataRow row in dtColumns.Rows) 
{ 
    if (mycolumnname==(string)row["COLUMN_NAME"]) flag = true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:26:50+00:00Added an answer on May 30, 2026 at 11:26 am

    This is code that is part of a o/r-mapper of mine. You cannot use it as is beacuse it depends on other classes, but I hope you get the picture.

    Define restrictions like this

    string[] restrictions = new string[] { null, null, tableName };
    

    This retrieves the columns from a table

    private void RetrieveColumnInfo(OleDbConnection cnn, TableSchema tableSchema,
              string[] restrictions, Func<string, string> prepareColumnNameForMapping)
    {
        using (DataTable dtColumns = 
                     cnn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, restrictions)) {
            string AutoNumberColumn = RetrieveAutoNumberColumn(cnn, tableSchema);
            foreach (DataRow row in dtColumns.Rows) {
                var col = new TableColumn();
                col.ColumnName = (string)row["COLUMN_NAME"];
                try {
                    col.ColumnNameForMapping =
                        prepareColumnNameForMapping(col.ColumnName);
                } catch (Exception ex) {
                    throw new UnimatrixExecutionException(
                        "Error in delegate 'prepareColumnNameForMapping'", ex);
                }
                col.ColumnAllowsDBNull = (bool)row["IS_NULLABLE"];
                col.ColumnIsIdentity = col.ColumnName == AutoNumberColumn;
                DbColumnFlags flags = (DbColumnFlags)(long)row["COLUMN_FLAGS"];
                col.ColumnIsReadOnly =
                    col.ColumnIsIdentity ||
                    (flags & (DbColumnFlags.Write | DbColumnFlags.WriteUnknown)) ==
                                                                   DbColumnFlags.None;
                if (row["CHARACTER_MAXIMUM_LENGTH"] != DBNull.Value) {
                    col.ColumnMaxLength = (int)(long)row["CHARACTER_MAXIMUM_LENGTH"];
                }
                col.ColumnDbType = GetColumnDbType((int)row["DATA_TYPE"]);
                col.ColumnOrdinalPosition = (int)(long)row["ORDINAL_POSITION"];
                GetColumnDefaultValue(row, col);
    
                tableSchema.ColumnSchema.Add(col);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since I write a command line program to check cpp files, and it need
I'm writing a 'Sudoku' program, and I need to write a method to check
My current program need to use programatically create a XPathExpression instance to apply to
In a program (Java) I'm making I need to check for a specific pin
I need to do a check to see if the file exists that they
Possible Duplicate: How to check if a program is installed on system I need
I need to write a program that checks a access .mdb file and when
I need my program to work only with certain USB Flash drives (from a
I need my program to create and edit a config file, which would contain
I need to generate multiple databases to SQL, so I need script/program to automatically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.