????? ??????? ?????? ?? Microsoft SQL Server ?? Microsoft Excel

?????? ????????? ?????? ?????????
???? ???????: 306125 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

??? ??? ?????? ???? ????? ??? ????? ??????? ???????? ??? Microsoft Excel ?? ????? ?????? Pubs? ????? ?????? ????? ??????? ?? Microsoft SQL Server.

?????? ?????? ActiveX (ADO) ???? ?????? ??? ?? ??? ?? ???? ????????. ?? ???? ???? ????? ?? ?????? ?????. ???????? ???????? ?? ????? ???? ADO:
   Object          Description
   -----------------------------------------------------------------------
   Connection      Refers to the connection to the data source.
   Recordset       Refers to the data extracted.
   Command         Refers to a stored procedure or SQL statements that 
                   need to be executed.
				
??? ????? ?? ?? ???? ?????? ?? ????? ?????? ?????? ????? ???????? ADO? ???? ??? ??????? ??? ??????? ??????? ?????? ???????.

???????

??? ?? ???? ???? ????? ?????? Microsoft SQL Server ????? ????? ??? ????? ?????? Pubs.

???? Microsoft ???? ????? ??? ???:
  • ????? Visual Basic ?? ??? ??????? ????????? ?? ????? Office.
  • ????? ???????? ??????? ????????.
  • ????? ?? ?????? Excel.
  • ?????? ????? ????? ????? ???????? (RDBMS) ?????????.
  • ?????? SELECT ??? ????????? (SQL) ???????.

?????? ??? ????? ?????? ADO

  1. ??? ????? Excel. ??? ???? ???? ????? ? SQLExtract.xls.
  2. ??? ????? ???? Visual Basic ???? ????? VBA.
  3. ??? ????? ???????? ???? ??? ?????.
  4. ???? ?????? ????? ???? ????? ?????? ?????? ActiveX Microsoft ???? ????????.

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

  1. ????? ???? ????? ????? ?? ???????.
  2. ????? ????? Sub ???? ???? ????????????.
  3. ???? ?? ???? ???????? ???????? ???????:
    ' Create a connection object.
    Dim cnPubs As ADODB.Connection
    Set cnPubs = New ADODB.Connection
    
    ' Provide the connection string.
    Dim strConn As String
    
    'Use the SQL Server OLE DB Provider.
    strConn = "PROVIDER=SQLOLEDB;"
    
    'Connect to the Pubs database on the local server.
    strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=pubs;"
    
    'Use an integrated login.
    strConn = strConn & " INTEGRATED SECURITY=sspi;"
    
    'Now open the connection.
    cnPubs.Open strConn
    					

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

???? ?? ???? ???????? ???????? ??????? ??? ??????? ??????? ?????? ??:
' Create a recordset object.
Dim rsPubs As ADODB.Recordset
Set rsPubs = New ADODB.Recordset

With rsPubs
	' Assign the Connection object.
	.ActiveConnection = cnPubs
	' Extract the required records.
	.Open "SELECT * FROM Authors"
	' Copy the records into cell A1 on Sheet1.
	Sheet1.Range("A1").CopyFromRecordset rsPubs
	
	' Tidy up
	.Close
End With

cnPubs.Close
Set rsPubs = Nothing
Set cnPubs = Nothing
				

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

  1. ????? ????????? ????????.
  2. ?? ???????? ??? Excel ????? ?? ?????? 1 ?? ?????? ??? ??? ????????.

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

??? ????????? ???????? ?????? ?? ???? ?????? ????? ??? ??? ???????? ?? ???? ???? ????? ???????? ????????. ????? ??????? ??????? ???????????????? ?????? ?? ????? ???? ??????? ?????? ??? ??? ???????. ????? ??? ??????? ??? ???? ???? ?? ?????. ??? ??? ?????? ?????? ??? ???? ???? ??????? ???? ??????. ?????? ?????????? 15 ?????.

?????

????? ?????? ??? ????????? ???????? ??????? ?????? ?????? ?? ???? Microsoft ?????? ??? ?????:
http://msdn.microsoft.com/

???????

???? ???????: 306125 - ????? ??? ??????: 27/????? ??????/1433 - ??????: 1.0
????? ???
  • Microsoft Office Excel 2007
  • Microsoft Excel 2002 Standard Edition
????? ??????: 
kbhowtomaster kbmt KB306125 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????306125

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

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com