Definition of Schema.ini:

Schema.ini files provide schema information about the records in a text file. Each Schema.ini entry specifies one of five characteristics of the table: the text file’s name; the file format; the field names, widths, and types; the character set; and special data type conversions.
You can use any text editor to create a Schema.ini file. In your Schema.ini file, you add entries, each of which specifies one of five characteristics of the text file: See below for a description of each

In fixed-width text files, Microsoft Access recognizes Null values by the absence of data (spaces) in the field. In delimited text files, Microsoft Access recognizes Null values by the presence of two consecutive delimiting characters.
Note Commas, tabs, or user-defined delimiters are valid in the source file.


Steps How to Create a Schema.ini Using The ODBC Manager


The purpose of a Schema.ini :

Microsoft Jet determines the format of a text file either by reading the file directly or by using a schema information file that overrides the default settings in the Windows Registry. The schema information file is always named Schema.ini. In order for Microsoft Jet to use the information in the Schema.ini file, you must store it in the same folder as the text data source. A Schema.ini file is always required for accessing fixed-width data, and is recommended when your text file contains Date/Time, Currency, or numeric floating-point data, or any time you want more control over handling the data in the text file. You do not need a separate Schema.ini file for each text file you want to link.


The text file name

The first entry in the Schema.ini file is always the name of the text source file enclosed in square brackets. The following example illustrates the entry for the file Sample.txt:

[SAMPLE.TXT]


The file format

The Format option in the Schema.ini file specifies the format of the text file, such as whether it is delimited or fixed-width. The text IISAM driver can read the format automatically from most character-delimited files. You can use any single character as a delimiter in the file except the double quotation mark. The Format option in Schema.ini overrides the Format setting in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Text key of the registry on a file-by-file basis. The following table lists the valid values for the Format option.

Format value File format
TabDelimited Fields in the text file are delimited by tabs.
CSVDelimited Fields in the text file are delimited by commas.
Delimited(*) Fields in the text file are delimited by asterisks. You can substitute any character for the asterisk except the double (") quotation mark.
FixedLength Fields in the text file are of a fixed width.
For example, to specify a comma-delimited format, you would add the following entry to the Schema.ini file: Format=CSVDelimited


Specifying the Fields

You can specify field names in a character-delimited text file in two ways: either include the field names in the first row of the table and set the ColNameHeader option in Schema.ini to True; or specify each column by number and designate the column name and data type. For fixed-length files, you must specify each column by number and designate the column name, data type, and width.

Note The ColNameHeader option in Schema.ini overrides the FirstRowHasNames setting in the registry on a file-by-file basis. If you use the ColNameHeader option to specify field names in a character-delimited file, you can also instruct Microsoft Jet to guess the data types of the fields.

Use the MaxScanRows option to indicate how many rows Microsoft Jet should scan when guessing the column types. If you set MaxScanRows to zero, Microsoft Jet scans the entire file. The MaxScanRows option in Schema.ini overrides the MaxScanRows setting in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines \Text key of the registry on a file-by-file basis.

The following example shows how to indicate that Microsoft Jet should use the data in the first row of the table to determine field names and should examine the entire file to determine the data types used:

ColNameHeader=True
MaxScanRows=0

The next example shows how to designate fields in a table by using the column number (Coln) option, which is optional for character-delimited files and required for fixed-length files. The example shows the Schema.ini entries for two fields, a 10-character CustomerNumber text field and a 30-character CustomerName text field:

Col1=CustomerNumber Text Width 10
Col2=CustomerName Text Width 30

The syntax of the Coln entry follows:
Coln=columnname type [Width #]
The following table describes each part of the Coln entry.

Argument Description

columnname

The text name of the column. If the column name contains embedded spaces, it must be enclosed in double quotation marks.

Type Value types are:

Microsoft Jet data types:
Bit (Boolean)
Byte
Short (Integer)
Long
Currency
Single
Double
Date/Time
Text
Memo

ODBC Text Driver data types:
Char (same as Text)
Float (same as Double)
Integer (same as Short)
LongChar (same as Memo)
Date date format
Width

The literal string value Width. Indicates that the following number designates the width of the column (optional for character-delimited files, required for fixed-length files).

#

The integer value that designates the width of the column (required if Width is specified).



The character set

The CharacterSet entry specifies which character set your computer uses. You can select from two character sets: ANSI and OEM. The following example shows the Schema.ini entry for an OEM character set. The CharacterSet option in the Schema.ini file overrides the CharacterSet setting in the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\3.5\Engines\Text key of the registry on a file-by-file basis. The following example shows the Schema.ini entry that sets the character set to ANSI:

CharacterSet=ANSI


Specifying Data Type Formats and Conversions

The Schema.ini file contains a number of options that you can use to specify how data is converted or displayed when read by Microsoft Jet. The following table lists each of these options.

See The VS6 Help files for the table mentioned.
Portions of the above information taken from the VS6 Help files. Copyright Microsoft

[Home]   [Back to the top]


Hosted by www.Geocities.ws

1