D
donbexcel
I'm trying to create a linked table in Access 2000 where the source is a
..TXT file using ADO. Even though I'm now using a schema.ini file, the
resulting linked file appears as a single column of information. It is not
being parsed correctly. Has anyone had this problem?
The code looks like this:
Function bSetDatasourceLinkFile(sTableName As String) As Boolean
Dim tblTable As New ADOX.Table
Dim cat As New ADOX.Catalog
bSetDatasourceLinkFile = True
cat.ActiveConnection = p_dbDatabase
On Error GoTo LocalHandler
If bTableExists(sTableName) Then
bDeleteTable sTableName
End If
tblTable.Name = sTableName
Set tblTable.ParentCatalog = cat
With tblTable
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Link Provider String") =
"Text;FMT=Delimited;HDR=YES;IMEX=2;CharacterSet=437;"
.Properties("Jet OLEDB:Link Datasource") = Left(p_sMSPath,
Len(p_sMSPath) - 1)
.Properties("Jet OLEDB:Cache Link Name/Password") = False
.Properties("Jet OLEDB:Remote Table Name") = "Demand daily#txt"
End With
cat.Tables.Append tblTable
Set tblTable = Nothing
Set cat = Nothing
Exit Function
LocalHandler:
MsgBox Err.Description
Set tblTable = Nothing
Set cat = Nothing
bSetDatasourceLinkFile = False
End Function
The schema.ini file looks like this:
[demand daily.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=25
CharacterSet=OEM
Col1="XPROD_CD" Char Width 200
Col2="MDL_NAME_CD" Char Width 200
Col3="MDL_FULL_YR" Integer
Col4="MDL_GRP_NAME" Char Width 200
Col5="MDL_SEG_NAME" Char Width 200
Col6="MDL_STAT_CD" Char Width 200
Col7="PROD_CTGY_NAME" Char Width 200
Col8="ORDER PROCESS (CR/C)" Float
Col9="ORDER PROCESS (SCH)" Float
Col10="ORDER PROCESS (SCHD)" Float
Col11="WHOLESALE (MTD)" Float
Col12="WARRANTY REGISTRATION (MTD)" Float
Col13="DEALER INVENTORY" Float
Col14="WAREHOUSE ID" Integer
Col15="GOOD" Float
Col16=HOLD/DAMAGED Float
Col17="IN TRANSIT" Float
Col18="JAPAN_MDL_TYP_CD" Char Width 200
Regards,
Don Buchanan
..TXT file using ADO. Even though I'm now using a schema.ini file, the
resulting linked file appears as a single column of information. It is not
being parsed correctly. Has anyone had this problem?
The code looks like this:
Function bSetDatasourceLinkFile(sTableName As String) As Boolean
Dim tblTable As New ADOX.Table
Dim cat As New ADOX.Catalog
bSetDatasourceLinkFile = True
cat.ActiveConnection = p_dbDatabase
On Error GoTo LocalHandler
If bTableExists(sTableName) Then
bDeleteTable sTableName
End If
tblTable.Name = sTableName
Set tblTable.ParentCatalog = cat
With tblTable
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Link Provider String") =
"Text;FMT=Delimited;HDR=YES;IMEX=2;CharacterSet=437;"
.Properties("Jet OLEDB:Link Datasource") = Left(p_sMSPath,
Len(p_sMSPath) - 1)
.Properties("Jet OLEDB:Cache Link Name/Password") = False
.Properties("Jet OLEDB:Remote Table Name") = "Demand daily#txt"
End With
cat.Tables.Append tblTable
Set tblTable = Nothing
Set cat = Nothing
Exit Function
LocalHandler:
MsgBox Err.Description
Set tblTable = Nothing
Set cat = Nothing
bSetDatasourceLinkFile = False
End Function
The schema.ini file looks like this:
[demand daily.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=25
CharacterSet=OEM
Col1="XPROD_CD" Char Width 200
Col2="MDL_NAME_CD" Char Width 200
Col3="MDL_FULL_YR" Integer
Col4="MDL_GRP_NAME" Char Width 200
Col5="MDL_SEG_NAME" Char Width 200
Col6="MDL_STAT_CD" Char Width 200
Col7="PROD_CTGY_NAME" Char Width 200
Col8="ORDER PROCESS (CR/C)" Float
Col9="ORDER PROCESS (SCH)" Float
Col10="ORDER PROCESS (SCHD)" Float
Col11="WHOLESALE (MTD)" Float
Col12="WARRANTY REGISTRATION (MTD)" Float
Col13="DEALER INVENTORY" Float
Col14="WAREHOUSE ID" Integer
Col15="GOOD" Float
Col16=HOLD/DAMAGED Float
Col17="IN TRANSIT" Float
Col18="JAPAN_MDL_TYP_CD" Char Width 200
Regards,
Don Buchanan