???? ID: 257819 - ????? ???????: 17 ??????? 2011 - ??????: 3.0 Visual Basic ?? VBA ?? ???? ?? Excel ?? ??? ADO ?? ????? ???? ????
?? ????? ?????????? ???? ????? ActiveX ???? ???????? ?? ????? ???? ?? (ADO) ???? ????? ?? ??? ??? Microsoft Excel ?????????? ?? ???? ?? ???? ?? ??????? ???????? ???????? ?? Excel ?? ??? ??????? ??????? ?? ???? OLAP ?? ????? ???? ?? ?? PivotTable ??????? ?? ???? ????? ?? ?? ????? ???? ?? Excel. ???????? ??????? ?? ???, ???? ?? ???? ?????? ?? ????? ?? ???? ?? Microsoft ???????? ??? ?????:: 303814
(http://support.microsoft.com/kb/303814/EN-US/
)
Visual Basic ?? VBA ?? ???? ?? Excel ?? ??? ADOX ?? ????? ???? ???? ???? ????????????????????? ?? ??????? ?? ???? Microsoft Excel ?????????? ?? closely resemble ????????? ?? ??????? ?? ?? ??????? ?????? ??? ?? ?? ?????????? ????? ?? Microsoft Excel ???? ?? ??? ??????? ??????? ??????? ?????? ??? ????, ?? ?? ???? imposes ?????? ?????, ????? sense ?????? ?? ???? ?? ???????? ???? ?? ??? Excel ?? ???? ??????? ?? ??? ???? ?? ??? ???? ???? ???Microsoft ActiveX ???? ???????? ??? ????? ?? ??? Excel ????????????? ?? ??? ???? ??????? ?? ?? ?? ??? ??? ????? ???? ??? ?? ???? ????? ???? ?? ?? ????? ???????? ??? ???? ???? ?? ??? ???? ????:
ADO ?? ??? Excel ?? ?????? ????ADO Excel ???? ????? ?? ?? OLE ?? ?? ?? ?? ??? ?????? ?? ???? DB ??????? MDAC ??? ????? ????:
Microsoft Jet OLE DB ??????? ?? ????? ???? ??????? ??????? ?? ???? Excel ???? ????? ?? ?????? ???? ?? ??? ??????? ?? ???? ?? ?????? ?? ????????: ??, ???? ??? ?? Excel ????? ??????? ????? ??????? ??????? ?? ??????? ???????? ?? ????? ???? ??????? ????? ISAM ??????? ???? ?? ???? ??? ??????? ???? ???? ??? ????? ????? ?? ????? ???? ??? ?? ADO ???? ???????? ?? ???? ?? ??????? ??? ?? ????? ???? ????????? ??????? ???? ????????? ??????? ???????? ??????? ???? ?? ??? ????? ????? ?? ????????? ???? ???? ???
Column headings: By default, it is assumed that the first row of your Excel data source contains columns headings that can be used as field names. If this is not the case, you must turn this setting off, or your first row of data "disappears" to be used as field names. This is done by adding the optionalHDR=setting to theExtended Propertiesof the connection string. The default, which does not need to be specified, isHDR=Yes. If you do not have column headings, you need to specifyHDR=No; the provider names your fields F1, F2, etc. Because theExtended Propertiesstring now contains multiple values, it must be enclosed in double quotes itself, plus an additional pair of double quotes to tell Visual Basic to treat the first set of quotes as literal values, as in the following example (where extra spaces have been added for visual clarity). Using Microsoft OLE DB Provider for ODBC DriversThe provider for ODBC drivers (which this article refers to as the "ODBC Provider" for the sake of brevity) also requires only two (2) pieces of information in order to connect to an Excel data source: the driver name, and the workbook path and filename.??????????: An ODBC connection to Excel is read-only by default. Your ADO RecordsetLockTypeproperty setting does not override this connection-level setting. You must setReadOnly???? ?? ??????in your connection string or your DSN configuration if you want to edit your data. Otherwise, you receive the following error message: Operation must use an updateable query. If you use the ADO Data Control or the Data Environment in your application, then theData Link Propertiesdialog box is displayed to gather the necessary connection settings.
Column headings: By default, it is assumed that the first row of your Excel data source contains columns headings, which can be used as field names. If this is not the case, you must turn this setting off, or your first row of data "disappears" to be used as field names. This is done by adding the optionalFirstRowHasNames=setting to the connection string. The default, which does not need to be specified, isFirstRowHasNames=1, ????1 = True. If you do not have column headings, you need to specifyFirstRowHasNames=0, ????0 = False; the driver names your fields F1, F2, and so forth. This option is not available in the DSN configuration dialog box. However, due to a bug in the ODBC driver, specifying theFirstRowHasNamessetting currently has no effect. In other words, the Excel ODBC driver (MDAC 2.1 and later) always treats the first row in the specified data source as field names.For additional informationon the Column Heading bug, click the article number below to view the article in the Microsoft Knowledge Base: 288343
(http://support.microsoft.com/kb/288343/EN-US/
)
BUG: Excel ODBC Driver Disregards the FirstRowHasNames or Header Setting Rows to Scan: Excel does not provide ADO with detailed schema
information about the data it contains, as a relational database would.
Therefore, the driver must scan through at least a few rows of the existing
data in order to make an educated guess at the data type of each column. The
default for "Rows to Scan" is eight (8) rows. You can specify an integer value
from one (1) to sixteen (16) rows, or you can specify zero (0) to scan all
existing rows. This is done by adding the optionalMaxScanRows=setting to the connection string, or by changing theRows to Scansetting in the DSN configuration dialog box.???????, ODBC ??????? ??? ??? ?? ?? ???? (MaxScanRows) ?? ????? ???? ?? ??? ????????? ????????? ???? ??? ??? ??? ?????? ???? ??? ????? ?????? ???, Excel ODBC ??????? (MDAC 2.1 ?? ??? ???) ????? ????? ???? 8 ????????? ????????? ???? ????? ??? ???????? ????? datatype ????????? ???? ?? ??? ????? ????? ??, ??? ??????? ?????? ????? ???? ?? ??? ????????? ?? ???? ??? ???????? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????: 189897
(http://support.microsoft.com/kb/189897/EN-US/
)
XL97: ???? ?? Excel ODBC ??????? ?? ??? 255 ???? ???? ???? ????????: ??? ???? ??????? ???????? ?? ????? ???? ????????? ???? ???????? ????? ???, ?? ???? ????? ??? ????????????? ??????????? ????? ??? ??????? ???????? ?? ??? ?????? ?????? ??, ???? ???? ???:Visual Basic ??????? ??????? ??? MDAC ?? ??? ????????? ?? ???, ?? ????? ??????? ??? ?????? ???? Excel ???? ????? ?? ???? ????????? ?????? ????? ???? ??? ??? ???? ???: ????? collating ??????? ???????? ?????? ?? ?????? ??????? ???? ??? 246167
(http://support.microsoft.com/kb/246167/EN-US/
)
PRB: Collating ??????? ?????? ????????? ADODB Recordset ????? ??? ?? ???? Excel XLS ?? ??????? ????? ?? ???? ???? ?? ??? ????? OLE DB ?????????????? ???? ?????? ?? ???? ??? ??? ??????????? ????????, ?? ??? ??? ADO Excel ?????????? ?? ?????? ??? ???????? ????? ?? ??? ???? ?????? ?? ?????? ????? ???? ????? (?? ?? ???? ?? ???????? ???????? ??????? Excel ????.) ?? ????? ?????? arise ?? ???? ??? ??? ???? ??? ?? ?? ????? ??? ??? ?? ??? ?? ??? ??????? ?????????? ??? ??? ??? ?? ODBC ??????? majority ?? ???? ?????, ????? minority ???? ?????? ?? ??? ?? (????) ??? ?? ???? ???? ???? ???? ?? ?????? ?? ????? ??? ??????? ?????? ?? ???, ??? ??????? ????? ???????? ??? ?? ??? ?????? ?? ???::
????-????? ?? ??? ???? ?? ??? ?? ?????? ?? ?? ???? ?? ??? ????? ???????? ????? ?????? ?? ????? ???? ??? "IMEX = 1" ??? ??????? ??? ?????? ?? ??????? ????????? ?? enforcesImportMixedTypes ??? =????????? ??????? ???????, ????? ??? ?? ?????? ?? ???? ?? ??? ????????? ?????? ?? ??? ??? ????? ?????? ?? ???? ??? ???????? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????: 194124
(http://support.microsoft.com/kb/194124/EN-US/
)
PRB: Excel ??? NULL DAO OpenRecordset ????? ?? ??? ??? ??? ?? ???????-?????? ????????????? ????? ??????? Excel ????????????? ?? ??????? ?????? ???????? ??, ?? ?? ??? ???? ???? ?? ???? ????? ?? ???, ???? ??? ??????? ???? ??????? ???????? ?? ??? ????????????? ???? ???? ?? ?? Microsoft Excel ????????? ??? ????? ?? ?? ?? ?? ?????? ??? ??? ???? ?? ?????? ??, ?? ???? ????? ?????? ????? ????? ??: ???? ?? ????????? ???? ?? ???? 211378
(http://support.microsoft.com/kb/211378/EN-US/
)
XL2000: "??? ???? ????????? ?????" ?????? ??????? ?? ???????? ????? ??????? ???? ?? ADO ?? ??? ???? ?? Excel ??? ???????? ?????? ??? ???? Excel ?? ??? ????? ???? ?? ?? ?????? ?? ????? ???? ?? ????:
???? ?? ??? ???? ?? ??? ???? ???????? ?? ??? ???? ?? ??? ?? ????? ???? ?? ?? ???? ???:
??? ?? ??? ???? ?? Excel ?? ??? ???????? Excel ???? ??? ????? ??? ?? ?? ???? ????????????? ??? ????? ???? ?? ???? ?? ???? ??:
???? recordsource ?? ??? ??? ??? ?????????? ????????? ????, ?? ???? ??? ?? ???? ????? ?? ???? ?????? ?????? surrounded ?????????? ??? ?? ????? ????? ?????? ?? ???:: ??? ?? ?? ?? ????? ????? ???? ????? ?? ??????, ?? ???? ???? ?????, ?? ???? ????? ?????? ????? ????? ??: ... Jet ??????? ????? ????????? ???????? ???? ??? ??? ???????? ?????? ??? ?? ???? ?????? ??? ???????? ??????? ?????? ?????? ?? ???? ???? recordsource ?? ??? ??? ???????? ?????? ?? ?????? ????????? ????, ???? ?? ??? ????? ????????? ??? ?? ????? ????? ?????? ?? ???:: ???? recordsource ?? ??? ??? ?? ???? ?????? ?? ?????? ????????? ????, ???? ?? ??? ???? Excel ??????/????? ?????? ???? ?????? ??? ????? ?? ??? ?? ??? ??? ?????? ?????? ?? ???:: ????????? ?? ????????? ???? ?? ???? ??? ??? ???????: ?? ?? ???? recordsource ?? ??? ??? ??? ?????????? ????????? ????, ??????? ?????? ?????? ???? ?? ?????? ??? ???? ?????????? ?? ??? ??? ????? ???? ??? ?? ?? ???? ?????? ????????? ???? (??? ?? unnamed), ??? ?? ?????? ?????? ???? ?? ?????? ??? ???? ?????? ?? ??? ??? ????? ???? ??? ???????, ??? ?? ??? ?????? ?? requery, ??? ???? recordset ????? ???? ???? ?? ?????? ?????? ?? ????? 2.5, ???? ?? ???? MDAC ????????? ?? ??? ???? ?? ??? ?????? ????????? ????, ?? ?? ?????? ????????? ???? ?? ???? ?? ?????? ??? ???? ?? ????, ?? ???? ????? ?????? ????? ??????? ???? ??: ???????? ?????? ??????? ???? ?? ???? ??? ADO ???? ???????? ?? ??? ???? ?? Excel ?? ??? ????After you specify the connection settings for your Excel data source on the???????tab of the ADODC???dialog box, click on theRecordsource??? ?? ????? ????.. If you choose a CommandType of adCmdText, you can enter a SELECT query in theCommand Textdialog box with the syntax described previously. If you choose a CommandType of adCmdTable, and you are using the Jet Provider, the drop-down list displays both the named ranges and worksheet names that are available in the selected workbook, with named ranges listed first.This dialog box properly appends the dollar sign to worksheet names, but does not add the necessary square brackets. As a result, if you simply select a worksheet name and clickOK, you receive the following error message later: Syntax error in FROM clause. Select Excel Data with Data Environment CommandsAfter setting up the Data Environment Connection for your Excel data source, create a newCommand???????? ??? If you choose aSource of DataofSQL Statement, ???? ???? ???? ???????? ?? ????? ?? ??? ????? ??? ??? ?????? ???? ?? ???? ???? ??? ?? ????? ??? ?????? ?????????????? ??????????? ??????????????? ??? ?????-???? ???? ???, ?? ?? ????? ??? ?? ??? ??? ???????, ?????-???? ???? ????????? ???????? ????????? ?? ?????????? ??? ????? ????????????? ??? ?????? ???????? ????????? ???????? ???? ?? ??? (??? ?? ?? ????? ??? ??? ?????????? ??? ????? ???, ?? ???? ???? ????? ?? ??? ?????????? ??? ?? ??-??? ???? ?????? ???????? ??? ?? ?? ??? ??? ?? ADO ???? ???????? ?? ??? ???? ???.) ??? ?? ODBC ??????? ?? ????? ?? ??? ???, ?? ?? ???????? ????????? ???? ?? ?????-???? ???? ??? ???????? ????? ???? ???????, ?? ?? ???? ??? ???????? ??? ?? ???? ?????????? ??? ???? ????????? ?? Excel ?? ????????? ???? ?? ??? ????: ??????, ?????? ?? ?????????????????? ADO ??????? ?? ??? ???? ?? Excel ??????? ?? ???? ??? ?? Excel ?????????? ?? Excel ??????? ??? (?????? "=" ?? ???) ???? ?? ???? Recordset ????? ????-????? ?? ??? ??? ?? ??????? ???? ???? ?? ???? ??? ??? ???? ?? Excel ?? ??? ??? ODBC ??????? ?? ???? ????? ?? ??? ???????? ??? ??, ??? ?? ???? ??????? ???????? ??? ?????? ????????? ???? ??? ????? ??????? ????? ?? ??? "????? Microsoft OLE DB ??????? ODBC ??????? ?? ???." add ????? ?? ?????? ???? ?? ???? ???? Excel recordsource ???? ?? ??? ?????? ?? ???? ????? ???????, ??? ?? ??? ??? ?? ????????? ?????? ?? ???? ?? ?????? ???, ?? ?????? ????? ???? ?? ??? ??? ?????? ?? ???????? ?? requery. "?? ??????? ????????? ????????? ???? ?? ???? ???." ?? ??????? ????? ??????? ????? ??? ????????????, ?? ?? ????? ??? ??AddNew, ????????ADO ?? ???????Recordset???????? ?? ???? Excel ??????, ADO ???? ?? ?? ????????? ???????? ???? ?? ??? ???? ????? Excel ??? ???? ??? ???????? ?? ???? ??????????? ??????? ?? ???, ???? ?? ???? ?????? ?? ????? ?? ???? ?? Microsoft ???????? ??? ?????:: 314763
(http://support.microsoft.com/kb/314763/EN-US/
)
FIX: Excel ??? ???? ????? ??? ADO ??????? ???? ??????? ???? ??????? ???? ????? ?? ???? Excel ???? ?? ????? ??? ?????????? ???? ?? ??????? ??????? ??? "??????" ?? "???????" apart existence ?? ???? ???? ??; ??? Excel ?????????? ??? ?? ???? ???? ??? ?? (??????) ????? ??? ??? ?? ??? ???? ???? ???????, ?? ????:
Excel ?? ???? ????? ?????? (????????) ??????? ????ADO ?? ??? ???? Excel ???? ????? (???????? ?? ?????) ?? ?????? ?? ???? ??? ???? ??????? ?? ???? ??? ??????? ?????? ??? ???? ?? ?? OLE DB ???????, ?? ??? ?????? ????? ?? ???? ?????? ?? ??????? ?????? ????? ?? ?? ?? ?? ?????? ?? ???????? ?? ??????? ??? ?? ???? ???OpenSchemaADO ?? ???????????????????, ?????? ??? ADO ???? ??Recordset???????? ??? ?? ?? ????? ?? ???? ?? ????? Microsoft ActiveX ???? ???????? ????????? ???? ???????? ???? ?? ??????? (ADOX) ????????? ?? ??? ?? ???????? ?? ???? ???? Excel ???? ????? ?? ????? ???, ???? ??? "??????" ???? ?????????? ?? ?????? ??? ??, ?? ?? "??????" ??????? datatypes ????? ?????? ??? ?? ?? ?? ?? ???????? ???? ???? ?????? ????????? ?????? ?????????????? ??????? ??????? ??? ?????? ???????? (??????, ?????, ???????? ???????????? ?? ??? forth), ???? Excel ???? ????? ?? ???? ?????? equivalents, ?????????? ?? ???????? ????????? ????????? ????????????? ??? ????????? ?? consisting exposes. "????????" ?? ??? ??? ???????? ????????? ???? ?? ??? ??? ?? ???????????? "?????? ????????" ?? ??? ??? ???? ??, ?? ?? "table_type" ?? ??? ?? ???? ??????? ?? ???? ??? ????? ?????? ?????? ??????? ???? ??? ?? ?????? ?????? ???????? ??? ????? ??? ?? ??? ????????????? ?? ?? ???? ??:
ODBC ??????? ??? ?? ?? (9) ?????, ?? ?? ?? populates ???? ?? ??? ?? recordset ???? ??? (3):
?????? ????? ??????????? Excel ???? ????? ??? ???????? ????? (?????) ??? ????? datatypes ??? ?? ?? ??:
???????? ?? ????? ?? ???? ??? ???????????? ?? ???? Excel ???? ????? ?? ???????? ?? ???? ??? ??????? ?????? ???????? ??? ??????? ?? ???? ???? ?? ??? Visual Basic ??? (???? ?? ????? ?????) ?? ????? ???? ?? ????? ?? ????? outputs ?? ???? ??????? ???? ?? ?????, List1, ?? ??? ???? ?????? ???????? ????? ????? ?? ????? ??????? ?? Visual Basic ???? ????? ????? ??? ???? Excel ???? ????? ?? ??? ??? ???? ???? ????? ???, ?? ???? ????? ????? ???? ???? ???? ?????? ????????? ??????? ?? ???? ??? ?? ?? ?? ??????? ????????? ???? ???? In particular, note that the Jet Provider lists both worksheets and named ranges under "Tables," where the ODBC Provider shows only named ranges. If you are using the ODBC Provider and have not defined any named ranges, the "Tables" list will be empty.Excel LimitationsThe use of Excel as a data source is bound by the internal limitations of Excel workbooks and worksheets. These include, but are not limited to:
??????For additional information about how to use ADO.NET to
retrieve and modify records in an Excel workbook with Visual Basic .NET, click
the following article number to view the article in the Microsoft Knowledge
Base: 316934
(http://support.microsoft.com/kb/316934/EN-US/
)
How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET For additional information, click the
article numbers below to view the articles in the Microsoft Knowledge Base:295646
(http://support.microsoft.com/kb/295646/EN-US/
)
How To Transfer Data from ADO Data Source to Excel with ADO 246335
(http://support.microsoft.com/kb/246335/EN-US/
)
How To Transfer Data from ADO Recordset to Excel with Automation 247412
(http://support.microsoft.com/kb/247412/EN-US/
)
???????: Visual Basic ?? Excel ??? ???? ??????????? ???? ?? ??? ??????? 278973
(http://support.microsoft.com/kb/278973/EN-US/
)
: ????? ????????? ???? ?? ExcelADO ?? ????? ?? ??????????????? ?? Excel ??? ???? ????? ADO ?? ????? ???? ???? 318373
(http://support.microsoft.com/kb/318373/EN-US/
)
Visual Basic .NET ??? GetOleDbSchemaTable ???? ?? ????? ?? Excel ?? ???????? ??????? ???? ???? ???? ???? ???? ??:
???? ?????? ??????????????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??. ?????????? ?? ??????? ????????? ??????? ??:257819
(http://support.microsoft.com/kb/257819/en-us/
)
| ???? ?????? ???? ?????? ??????
????????? ?????? ??????? ???????? ??????
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email

????? ?? ???? ????
