Microsoft Access, ?? ?? ???? ???? ??? (???????) ???? ????? ?????? ??? ODBC ??????? ?? ????? ?? ??? ??, ???? ??????? ??? ?? ?????? ?? ??? ??????? ?? ?????????? ID ?? ???????? ???? ?? ??? ??????? ??? ?? ??????? ??? ?? ??????? ?? ID ???? ??????, ???? ????? ???? ????? ??? ??? ??? ??????? ?? ??? ?? ?????? ?? ??????
??? ?? ActiveX ???? ???????? (ADO) ?? ?????? ?? ?????? ????? ???, ?? ???? ?? ??-???? ?????? ??????? ???? ??:
"-2147467259(80004005) ODBC--'?????' ?? ??? ??????? ????"
?????? ?? ???? ??, ??????? ?????? ???????? ????? ???? ???
?? ???? ????????? ???? ?? ?? ?? ??????? ?? providing ?????????? ID ?? ????????? Visual Basic ??? ??????? ?? pre-connecting ?????? ADO ??? Microsoft Access ???? ?? ?? ?????? ????? ?? ??? ???? ?????
Microsoft ???????? ????
177594
(http://support.microsoft.com/kb/177594/EN-US/
)
?????? ????? ????????? ?? ?????? ?????? ????? ???? ????
????? ?? ?? ?? ????????? ???? ?? ??? ????? ???? ?? ??? ???? ????? ???????? (DAO)? ???????, ?? ???? ?????? ADO ????? DAO, ??? ??? ??????? ??? ???? Microsoft Jet ?? ?? ?????? ?? ????? ?? ??? ???
?? ??????? ?? ??? ??????? ?? ??? ??? ?????? ?????? ADO, ??? ???????? ??????? Microsoft Jet ?? ?? ??? ?????? ????? ?? ??? ??????? ?? ?? ??????? ??? ???? ??????? ???? ?? ??? ?????? ???? ???
??? ?????? ???:
- ODBC ???? ????? ?? ???? ??? ??? ?? ???? ?? ?????? ADO ??? ?????? ?? ???? ?? ??? ?? ???????? ??? Drawback ?? ?? ?? ????? ?????? ???? ???? ODBC ?? ??? ?????? ?? ??? heterogeneous joins ?? ??? ???
- ?? ???? ?? ?? ?????? ??? ??? ??, ?? ???? ?? ?? ??? ?? ??? ??? ???????? ?????????? ??????? ?? ??? ?????? ??? ?? ?? ?? ?? ??????? ??? ???? ?? ??? heterogeneous joins ?? ?? ???? ???? Drawback ?? ?? ???????? ?????????? ?? ?? ??????? ??????? ???? ??? ??? ??, ??????? ?? ??? ???? ??? ?? ?? ?????? ???? ?? ?? ?????? ????? ?? ??? ?????? ?? ????? ?? ???? ???? ?? ??-??? ??????? ??????? ?? ?????????? ??????? ?? ????? ?? ????????? ???????, ?? ???????
- Pre-authenticate ODBC ????? ?? ??? ?? ?????? ?? ???? ???????? ??? ????? ??? ???? ??? ?????? ?? ???? ????? ?? ????? ?? ??? ??? ??? ?? ?? ?? ?? ?? ?????? ??? ??? ??????? ?????? ??????? ?? ???, ???????? ?????????? ?? ??? ??????? ?? ???? ???, ?? ?? ??????? ??? ???? ?? ??? joins ?? ???? ????
ADO ??? ODBC ????? pre-authenticate, ???? ?? ??? ?? ??? ?? ?? ???? ?? ?? ?????? ????? ????? ?? ??????? ?? ????? ???? ????? Microsoft Jet ?? ???????? ???? ????? ??????? ?? ???????? ???? ?? ??? ?????? ????? ?? ?? ??? ?????????? ????? ?????
????? ????????? ??????? illustrate ???? ?? ??? "pubs" Microsoft SQL Server ??????? ?? ????? ???? ??? ????? ???????? ?? ??? ?? ???? ??? ????? ?? pre-authentication ??? ??? ????? ???? ?? ??? ??? ?????? ???? ??? ?????? ??? ???? ????
- Microsoft Access 2000 ??? NorthWind.mdb ????? ?? ODBC ???? ????? ?? ???? ?????? ?? ???? ????? ?? ?????? ???, ???? ?? ?? ?????? MyServer, Pubs ??????? ?? ?????? ?????? ?? ???? ????? ??? (DSN) ????? ???? ??? ??????? ?????? ?????
- Microsoft Visual Basic ??????? 5.0 ?? ????????? ???? ??, 6.0 ??? ???????????and add a reference to the Microsoft ActiveX Data Objects
(version 2.1 or later) Library.
- Add two command buttons (cmdOpenLink and
cmdPreAuthenticate).
- Add the following code to the form's module:
???:You must change User ID=<user id=""> and password=<strong password=""> to the correct values before you run this code. Make
sure that User ID has the appropriate permissions to perform this operation on
the database.</strong></user>
Option Explicit
Dim cn As ADODB.connection
Private Sub cmdOpenLink_Click()
'
' Opens a linked table
'
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.open "dbo_authors", cn, adopenkeyset, adlockoptimistic, adcmdtable
rs.movelast
Debug.Print "There are"; rs.recordcount; "records."
rs.Close
End Sub
Private Sub cmdPreAuthenticate_Click()
'
' Opens a dummy recordset on a table using the same connection properties
' as the linked table. This could be a dummy UPDATE statement to avoid the
' overhead of recordset creation.
'
Dim rs As ADODB.Recordset
Set rs = cn.execute("SELECT * FROM [ODBC;DSN=MyServer;uid=<User ID>;pwd=<Strong Password>;database=pubs].Authors WHERE FALSE")
rs.close
End Sub
Private Sub Form_Load()
Set cn = New ADODB.connection
cn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
End Sub
- Run the application and open the form. ????? ????,cmdOpenLink. You will receive a run-time error.
- End the application and restart. ????? ????,cmdPreAuthenticate?? ????-????? ????, ?? ???? ???cmdOpenLink. TheDebug/Immediatewindow will display the record count.
???? ID: 245587 - ????? ???????: 02 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
| kbclient kbdatabase kbhowto kbjet kbmt KB245587 KbMthi |
???? ?????? ??????????????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:
245587
(http://support.microsoft.com/kb/245587/en-us/
)