We€™re calling ADOX::Table::Keys::Append to make a primary key for a table using the SQLOLEDB provider. We€™re passing an ADOX::Key with Name set to a custom name, Type set to ADOX::adKeyPrimary, and a single column added. For the Append call, the 2nd parameter is ADOX::adKeyPrimary, the third is a vtMissing (VT_ERROR with DISP_E_PARAMNOTFOUND), the last two are empty BSTR€™s. On XP, this works well (msadox.dll file version 2.81.1117.0). On Vista, this fails with an invalid parameter error (msadox.dll version 6.0.6000.16386). Has the interface changed in some way, is this functionality not supported, or is it broken?
I want to add new column 'firstaname' into the existing table "geo" already two columns namely
'salcode' 'lastname'.I run the following code it runs without error, when i opened the database see the structure of table, i didn't find new column in the table "geo"
I have been pulling my hair trying to figure out what the guys at microsoft were thinking when creating the ADOX library. I have an access table that is syncronized with a SQL server. The table has a primary key with two columns [User] and [Program]. The SQL Server has both columns in as the primary key columns and I have a syncronization mechanism that is responsible for several things, one of which is to recreate the Access data structure. All works well for all tables except this one. I have tried to create the multi-column key in several ways, none that worked. Let me show you what I am doing:
I need to programatically create a mdb file which will contain nullable columns. I am using C++ with ADOX for the table creation and ADO to perform the table update.
Although ADOX seems to create the table ok, Table->Columns->Appends does not set the fields as adColNullable as expected.
When I insert data using ADO::Recordset->AddNew the following error occurs :- "The field 'MyTable.Column 2' cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field."
Am I on the right tracks here or do I need to adopt a different approach?
I'm using ADOX 2.8 for table creation: The following is an example of a column defintion:
If CreateNewTable Then CreateNewTable = a.CreateColumn("ReferenceCount", ADOX.DataTypeEnum.adInteger)
If CreateNewTable Then CreateNewTable = a.CreateColumn("Document", ADOX.DataTypeEnum.adLongVarBinary) 'Oleobject
If CreateNewTable Then CreateNewTable = a.CreateColumn("EntityID", ADOX.DataTypeEnum.adWChar, 18) 'text
Where CreateColumn looks like this:
Public Function CreateColumn(ByVal ColumnName As String, ByVal Datatype As ADOX.DataTypeEnum, Optional ByVal Size As Integer = 0) As Boolean
'ADOX.CreateColumn - Called by Common.CreateNewTable 'CreateColumn creates a column described in the Table object so it assumes it is set. 'One method of setting it is to call Select Table after opening the database
If Not Me.ConnectionIsOpen Then MsgBox("CreateColumn - Failed to Create Column : " _ & ColumnName, MsgBoxStyle.Exclamation, cNoConn) Return False End If
Dim col As New ADOX.Column col.Name = ColumnName Try col.Type = Datatype Catch e As Exception MsgBox("CreateColumb - Failed to Create Column : " _ & ColumnName, MsgBoxStyle.Exclamation, e.Message) col = Nothing Return False End Try
If Size <> 0 Then col.DefinedSize = Size Try
Table.Columns.Append(ColumnName, Datatype)
Catch e As Exception If Err.Number() <> 0 Then MsgBox(Err.Source & "-->" & Err.Description, , "Error") End If MsgBox("CreateColumb - Failed to Append Column : " _ & ColumnName, MsgBoxStyle.Exclamation, e.Message) Return False End Try col = Nothing Return True End Function
in CreateColumn("EntityID", ADOX.DataTypeEnum.adWChar, 18)
the 18 specifies the field width in the database. Yet no matter whether I use adWChar or
adVarWChar, Access always shows the field size to be 255.
I am using ADOX to create linked tables in a jet database from an ODBC datasource. The tables in the ODBC data source does not have a primary key. so I am only able to create read only linked tables.But I want to update the records also. I tried adding a primary key column to the linked table while creating the link. but I am getting an error while adding the table to the catalog.
The error message is "Invalid Argument".
I use the following code for creating the linked table
Sub CreateLinkedTable(ByVal strTargetDB As String, ByVal strProviderString As String, ByVal strSourceTbl As String, ByVal strLinkTblName As String)
Dim catDB As ADOX.Catalog Dim tblLink As ADOX._Table
' Name the new Table and set its ParentCatalog property ' to the open Catalog to allow access to the Properties ' collection. .Name = strLinkTblName .ParentCatalog = catDB
' Set the properties to create the link. Dim adoxPro As ADOX.Property
The first line of code works fine but when I try to set the value of the property I get the following excpetion:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in MyDll.dll Additional information: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.