Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 279245 - Last Review: November 25, 2003 - Revision: 3.3
FIX: Default Column Properties Cleared When You Set or Check Values by Using ADOX to an Access Database
This article was previously published under Q279245
When you set or check the default column values for any column in a table that is contained in an Access 2000 database, the default values for the column are cleared.
To resolve the problem, install the latest service pack for Microsoft Jet 4.0. Prior to installing the latest Jet 4.0 service pack, Microsoft recommends that you look at the following Microsoft Knowledge Base article for information and issues for downloading:
239114Â
(http://kbalertz.com/Feedback.aspx?kbNumber=239114/
)
How To: Obtain the Latest Service Pack for the Microsoft Jet 4.0 Database Engine
For your reference, this article is updated periodically to provide you with the most up-to-date information regarding future Jet service packs.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
This problem can be fixed by installing the latest Jet 4.0 service pack.
Note that there are some issues that you need to be aware of when applying the Jet service pack onto a Windows 2000-based computer. The following white paper titled "The MDAC 2.5 Stack and Windows File Protection" contains a full list of the components that are shipped with MDAC 2.5, along with a discussion of Windows File Protection.
Also refer to this white paper for more information on the Jet dynamic-link libraries (DLLs) that are shipped in MDAC 2.5 and that are no longer a part of MDAC 2.6.
Steps to Reproduce Behavior
- Run Microsoft Visual Basic, and create a Standard EXE project. Form1 is created by default.
- On the Project menu, click References, and then add references to the following:
- Microsoft ActiveX Data Objects 2.6 Library
- Microsoft ADO Ext. 2.6 for DDL and Security
- Add a Command button to Form1.
- Add the following code to Form1:
Option Explicit
Private Sub Command1_Click()
On Error GoTo ErrHandler 'Intercept any errors
Dim strConn As String 'Work
Dim strDBPath As String 'Path for new database
Dim DBCatalog As ADOX.Catalog 'ADOX catalog reference
Dim DBTable As ADOX.Table 'Database table definition
Dim DBColumn As ADOX.Column 'Column object within a table
strDBPath = "C:\TestDB.mdb" 'Path for database
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
Set DBCatalog = New ADOX.Catalog 'Database root schema object
DBCatalog.Create strConn 'Create new database
Set DBTable = New ADOX.Table 'Create a new table object
DBTable.Name = "TestTable" 'Set name of table
Set DBTable.ParentCatalog = DBCatalog 'Make Properties collections available
'---Create a column in the table...
Set DBColumn = New ADOX.Column 'Column object to define
With DBColumn 'Reference new column
.Name = "TestColumn" 'Name the column
.Type = adInteger 'Type of data
.DefinedSize = 0 'Normal size of data
.Attributes = adColFixed 'Column attribute flags
.NumericScale = 0 'Numeric scaling factor
.Precision = 10 'Digits of Precision
End With 'Done with DBColumn reference
DBTable.Columns.Append DBColumn 'Add column to table
'---Add new table to the database...
DBCatalog.Tables.Append DBTable 'Add table to database
Set DBTable = DBCatalog.Tables("TestTable") 'Reference new table object
DBTable.Columns("TestColumn").Properties("Default").Value = 5 'Set value for property
Exit Sub
ErrHandler:
MsgBox "Error: " & Err.Number & " " & Err.Description
End Sub
- Set strDBPath to a database name to be created.
APPLIES TO
- Microsoft Data Access Components 2.5 Service Pack 1
- Microsoft Data Access Components 2.5
- Microsoft OLE DB Provider for Jet 4.0
| kbbug kbfix kbmdacnosweep KB279245 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please