Home > Software engineering > I want to use ADO SQL query EXCEL, but can not get the result, can help me find the reason
I want to use ADO SQL query EXCEL, but can not get the result, can help me find the reason
Time:10-11
I want to use ADO + SQL query EXCEL, but can not get the result, can help me find the reason, thank you
Public xlApp As Excel. Application class defined Excel ' . Public xlBook As Excel Workbook 'class definition artifacts book Public xlsheet As Excel. The Worksheet 'definition Worksheet class Private Sub Command1_Click () FileName="warehouse. XLS" The Set xlApp=GetObject (" Excel. Application "), 'whether Excel open XlApp. WindowState=xlMaximized The Set xlBook=xlApp. Workbooks. Open (App) Path & amp; "" & amp; FileName) 'open workpiece book file XlApp. Visible=True Set the CNN=CreateObject (" ADODB. Connection ") The Set rst2=CreateObject (" ADODB. You ") 'Set xlsheet=xlBook. Worksheets (4) 'xlsheet. Unprotect "123 ABC" 'xlsheet. Range (" J, J). ClearContents
CNN. Open the provider="Microsoft. Jet. The oledb. 4.0; Extended properties=8.0 Excel; Data source="& amp; App. The Path & amp; "" & amp; FileName StrSQL="SELECT * FROM [" & amp; Sh. The Name & amp;" $] " StrSQL="SELECT * FROM [balance $] where material name='JACK IN THE BOX", " StrSQL="SELECT * FROM [balance $]" 'Set rst2=CNN. The Execute (" SELECT material name, specifications, outbound, outbound people FROM [outbound $] where name=' TARGET.COM 'material and outbound way=' procurement warehousing ") The Set rst2=CNN. The Execute (StrSQL) The Set xlsheet=xlBook. Worksheets (2) Xlsheet. Range (" a5 "). CopyFromRecordset rst2 For I=1 To 2 'rst2. Fields. The Count' SQL access To the results of column headings 'MsgBox rst2. Fields (I - 1). The Name' field Name, 'MsgBox rst2. Fields (I - 1)' field name,