JET SQL 可以更改欄位型別,無法更改欄位名的,除非你連續使用幾個JET SQL 先刪除欄位然後再插入欄位,然後用UPDATE查詢將儲存再臨時表的原欄位資料恢復過來。或者,直接用 ADOX 更改 TABLE 的 Columns(欄位名) 物件的 NAME 屬性即可。Function Test() ChangeTableFieldName_ADO "表1", "aa", "pic1"End Function Function ChangeTableFieldName_ADO(MyTableName As String, MyFieldName As String, strNewName As String) "3個引數: "MyTableName 字串,表名 "MyFieldName 字串,原來的欄位名 "strNewName 字串,新的欄位名 "記得先引用 ADOX Dim MyDB As New ADOX.Catalog Dim MyTable As ADOX.Table MyDB.ActiveConnection = CurrentProject.Connection Set MyTable = MyDB.Tables(MyTableName) MyTable.Columns(MyFieldName).Name = strNewNameEnd Function
JET SQL 可以更改欄位型別,無法更改欄位名的,除非你連續使用幾個JET SQL 先刪除欄位然後再插入欄位,然後用UPDATE查詢將儲存再臨時表的原欄位資料恢復過來。或者,直接用 ADOX 更改 TABLE 的 Columns(欄位名) 物件的 NAME 屬性即可。Function Test() ChangeTableFieldName_ADO "表1", "aa", "pic1"End Function Function ChangeTableFieldName_ADO(MyTableName As String, MyFieldName As String, strNewName As String) "3個引數: "MyTableName 字串,表名 "MyFieldName 字串,原來的欄位名 "strNewName 字串,新的欄位名 "記得先引用 ADOX Dim MyDB As New ADOX.Catalog Dim MyTable As ADOX.Table MyDB.ActiveConnection = CurrentProject.Connection Set MyTable = MyDB.Tables(MyTableName) MyTable.Columns(MyFieldName).Name = strNewNameEnd Function