|
-
Jun 10th, 2003, 11:17 AM
#1
Thread Starter
Frenzied Member
Delete *fields* from a table **RESOLVED**
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
Last edited by ae_jester; Jun 10th, 2003 at 11:44 AM.
-
Jun 10th, 2003, 11:21 AM
#2
PowerPoster
Well
VB Code:
Sub AlterTableX2()
Dim dbs As Database
' Modify this line to include the path to Northwind
' on your computer.
Set dbs = OpenDatabase("Northwind.mdb")
' Delete the Salary field from the Employees table.
dbs.Execute "ALTER TABLE Employees " _
& "DROP COLUMN Salary;"
dbs.Close
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Jun 10th, 2003, 11:43 AM
#3
Thread Starter
Frenzied Member
Yah thats it! I learned in it first year, but forgot how. Thanks
-
Jun 10th, 2003, 11:49 AM
#4
PowerPoster
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|