Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Adding field with ADOX


Reply
 
Thread Tools Display Modes
  #1  
Old 10-17-2001, 06:49 AM
Mike Mike is offline
Contributor
 
Join Date: Apr 2001
Location: Montreal, Canada
Posts: 428
Question Adding field with ADOX


I'm trying to add a field to a table using ADOX. Adding the field is easy but I can't figure out how to set its default value. What should I add to the following code?

Dim oCat As ADOX.Catalog
Dim oTable As ADOX.Table
Dim oColumn As ADOX.Column

Set oCat = New ADOX.Catalog

oCat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= MyDatabase.mdb;"
Set oTable = oCat.Tables("MyTable")
Set oColumn = New ADOX.Column
With oColumn
.Name = "NewField"
.Type = adUnsignedTinyInt
End With

oTable.Columns.Append oColumn

Set oColumn = Nothing
Set oTable = Nothing
Set oCat = Nothing

Thanks!
Reply With Quote
  #2  
Old 10-17-2001, 09:32 PM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Lightbulb Re: Adding field with ADOX

well I've never used ADOX (?) but I've made a few tables in my time;
just look at 'oColumn' in your 'Locals' window (VBE - Tools menu) and examine its properties - everything will (should) become clear...
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #3  
Old 10-18-2001, 01:21 AM
Robby's Avatar
Robby Robby is offline
Code Factory

Retired Moderator
* Expert *
 
Join Date: Jan 2001
Location: Montreal, Ca.
Posts: 5,565
Default Re: Adding field with ADOX

I know this is silly and you probably tried it. Is there a .DefaultValue (in the list).
__________________
Visit...Bassic Software
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->