一个人将如何访问Microsoft Access中主键的字段属性?

时间:2019-06-25 20:53:49

标签: c# ms-access oledb

我正在开发一个程序,以快速检查.mdb文件中的所有表,以确保其主键属性均未更改。但是,我很难弄清楚如何检查主键的字段属性。

我已经设法使用OleDbSchemaTable获取所有主键及其架构。但是,它列出的属性与我要查找的不完全相同。

{
    "$connections": {
        "value": {
            "azureblob": {
                "connectionId": "/subscriptions/[GUID]/resourceGroups/StackOverFlow/providers/Microsoft.Web/connections/azureblob",
                "connectionName": "azureblob",
                "id": "/subscriptions/[GUID]/providers/Microsoft.Web/locations/westeurope/managedApis/azureblob"
            },
            "excelonlinebusiness": {
                "connectionId": "/subscriptions/[GUID]/resourceGroups/StackOverFlow/providers/Microsoft.Web/connections/excelonlinebusiness",
                "connectionName": "excelonlinebusiness",
                "id": "/subscriptions/[GUID]/providers/Microsoft.Web/locations/westeurope/managedApis/excelonlinebusiness"
            },
            "onedriveforbusiness": {
                "connectionId": "/subscriptions/[GUID]/resourceGroups/StackOverFlow/providers/Microsoft.Web/connections/onedriveforbusiness",
                "connectionName": "onedriveforbusiness",
                "id": "/subscriptions/[GUID]/providers/Microsoft.Web/locations/westeurope/managedApis/onedriveforbusiness"
            }
        }
    },
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose": {
                "inputs": "@body('Get_blob_content')",
                "runAfter": {
                    "Get_blob_content": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "For_each_row": {
                "actions": {
                    "Add_a_row_into_a_table": {
                        "inputs": {
                            "body": {
                                "Hours": "@body('Parse_JSON')?['PackageServiceId']",
                                "Id": "@body('Parse_JSON')?['ActiveUsers']",
                                "Name": "@body('Parse_JSON')?['AgreementID']"
                            },
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['excelonlinebusiness']['connectionId']"
                                }
                            },
                            "method": "post",
                            "path": "/codeless/v1.2/drives/@{encodeURIComponent('[Some long hash]')}/items/@{encodeURIComponent('[Some long hash]')}/workbook/tables/@{encodeURIComponent('{[GUID]}')}/rows",
                            "queries": {
                                "source": "me"
                            }
                        },
                        "metadata": {
                            "[Some long hash]": "/LOL/Bok1.xlsx"
                        },
                        "runAfter": {
                            "clear_tempArray_for_next_row": [
                                "Succeeded"
                            ]
                        },
                        "type": "ApiConnection"
                    },
                    "Clear_data_of_special_characters": {
                        "description": "replace(replace(replace(item(),'[',''),']',''),'\"','')",
                        "inputs": {
                            "name": "data",
                            "value": "@{replace(replace(replace(item(),'[',''),']',''),'\"','')}"
                        },
                        "runAfter": {},
                        "type": "SetVariable"
                    },
                    "For_each_item_on_row": {
                        "actions": {
                            "Append_to_tempArray": {
                                "description": "Create array to hold values before compose and json",
                                "inputs": {
                                    "name": "tempArray",
                                    "value": "@items('For_each_item_on_row')"
                                },
                                "runAfter": {},
                                "type": "AppendToArrayVariable"
                            }
                        },
                        "description": "split(variables('data'),',')",
                        "foreach": "@split(variables('data'),',')",
                        "runAfter": {
                            "Clear_data_of_special_characters": [
                                "Succeeded"
                            ]
                        },
                        "type": "Foreach"
                    },
                    "Parse_JSON": {
                        "description": "Parse into json object",
                        "inputs": {
                            "content": "@variables('data')",
                            "schema": {
                                "properties": {
                                    "ActiveUsers": {
                                        "type": "string"
                                    },
                                    "AgreementID": {
                                        "type": "string"
                                    },
                                    "PackageServiceId": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            }
                        },
                        "runAfter": {
                            "Set_data_to_json_formated_string": [
                                "Succeeded"
                            ]
                        },
                        "type": "ParseJson"
                    },
                    "Set_data_to_json_formated_string": {
                        "description": "Create json string using tempArray: variables('tempArray')?[0] throu variables('tempArray')?[2]",
                        "inputs": {
                            "name": "data",
                            "value": "{\n\"AgreementID\":\"@{variables('tempArray')?[0]}\",\n\"PackageServiceId\":\"@{variables('tempArray')?[1]}\",\n\"ActiveUsers\":\"@{variables('tempArray')?[2]}\"\n}"
                        },
                        "runAfter": {
                            "For_each_item_on_row": [
                                "Succeeded"
                            ]
                        },
                        "type": "SetVariable"
                    },
                    "clear_tempArray_for_next_row": {
                        "inputs": {
                            "name": "tempArray",
                            "value": "@null"
                        },
                        "runAfter": {
                            "Parse_JSON": [
                                "Succeeded"
                            ]
                        },
                        "type": "SetVariable"
                    }
                },
                "description": "split on newline in csv doc. @split(body('Get_file_content'),'\\r\\n')",
                "foreach": "@split(outputs('Compose'),'\r\n')",
                "runAfter": {
                    "Initialize_'data'_string": [
                        "Succeeded"
                    ]
                },
                "runtimeConfiguration": {
                    "concurrency": {
                        "repetitions": 1
                    }
                },
                "type": "Foreach"
            },
            "Get_blob_content": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent('[Some long hash]'))}/content",
                    "queries": {
                        "inferContentType": true
                    }
                },
                "metadata": {
                    "[Some long hash]": "/stackoverflow/blob.csv"
                },
                "runAfter": {
                    "Get_file_content": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            },
            "Get_file_content": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['onedriveforbusiness']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent('[Some long hash]'))}/content",
                    "queries": {
                        "inferContentType": true
                    }
                },
                "metadata": {
                    "[Some long hash].[Some long hash]": "/LOL/Bok1.csv",
                    "[Some long hash].[Some long hash]": "/LOL/Bok1.xlsx",
                    "[Some long hash].[Some long hash]": "/LOL/ReadStuff.csv"
                },
                "runAfter": {},
                "type": "ApiConnection"
            },
            "Initialize_'data'_string": {
                "inputs": {
                    "variables": [
                        {
                            "name": "data",
                            "type": "String"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_'tempArray'_array": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "Initialize_'tempArray'_array": {
                "inputs": {
                    "variables": [
                        {
                            "name": "tempArray",
                            "type": "Array"
                        }
                    ]
                },
                "runAfter": {
                    "Compose": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Month",
                    "interval": 3
                },
                "type": "Recurrence"
            }
        }
    }
}

这是我想获得的信息:

  

***** TABLE_NAME *****

     

PRIMARY_KEY_NAME

     

字段大小=长整数

     

新值=增量

     

格式=

     

标题=

     

索引=是(重复确定)

     

文本对齐=常规

代替此:

  

***** TABLE_NAME *****

     

PRIMARY_KEY_NAME

     

TABLE_CATALOG =

     

TABLE_SCHEMA =

     

TABLE_NAME = TABLE_NAME

     

COLUMN_NAME = PRIMARY_KEY_NAME

     

COLUMN_GUID =

     

COLUMN_PROPID =

     

ORDINAL = 2

     

PK_NAME = PrimaryKey

这是我要获取的信息: https://imgur.com/a/pXCLB9e

0 个答案:

没有答案