Hi,
I need a way to delete a field from a table. Is there any SQL command that can do this, or would I have to use ADO, or something else?
These fields are part of an 'extra data' table which my program reads and lists all the fields so the user can add data that isnt in any existing table.
By the way, I am using this code to Add a field to a table (which works great), but I can't figure out how to modify it so that it will let me delete a field. Anyone know?
VB Code:
Public Sub CreateADOField(DbFile As String, strTablename As String, _ strFieldName As String, Style As Variant, Optional intLenght As Integer) On Local Error Resume Next ' Add to references ' Microsoft ADO Ext. 2.x for DDL and Security Dim cat As New ADOX.Catalog Dim tbl As New ADOX.Table Dim Col As New ADOX.Column cat.ActiveConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ DbFile & ";" Col.name = strFieldName Col.Attributes = adColNullable If intLenght > 0 Then Col.DefinedSize = intLenght Col.Type = Style cat.Tables.Item(strTablename).columns.Append Col cat.Tables.Item(strTablename).columns.Item(strFieldName).Properties("Jet OLEDB:Allow Zero Length") = True ' use field properties to set parameters Set cat = Nothing End Sub




Reply With Quote