|
楼主 |
发表于 2011-4-12 16:11
|
显示全部楼层
下面这段程序有问题吗? 我按命令按钮后,提示下标越界的错误。前两天运行还没问题的啊
Dim conn As New ADODB.Connection
Dim sql As String
Dim rs As ADODB.Recordset
Private Sub CommandButton1_Click() '2éÑˉTCX Cell for test
'Set conn = CreateObject("adodb.connection")
'conn.Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;hdr=yes';data source=" & ThisWorkbook.Path & "\dbku.xls"
conn.Open "rovider=SQLOLEDB.1;Data Source=logic-E5400;Initial Catalog=TCX_20101208;User ID=saassword=sgmw5050ersist Security Info=False;"
sql = "select ix1.item_id Product_SN,ix1.component_item_id BASE_QR,ix2.component_item_id BOOSTER_QR,ph2.VAL_1 as BASEWELD_Volts,ph3.VAL_3-ph3.VAL_1,ph1.VAL_3 Resistance from process_history ph1,item i, item_xref ix1,item_xref ix2,process_history ph2,process_history ph3 where ph1.item_id=i.item_id and i.operation_id=999 and i.item_type='SERIALIZED' and i.item_id not like '%TCX%' and ph1.item_id=ix1.item_id and ix1.component_item_id not like '1T%'and ix1.component_item_id=ix2.item_id and ix2.component_item_id not like '1T%' and ph2.source_id='C-CT4' and ph2.item_id=ix1.component_item_id and ph1.source_id='C-CT15'and ph3.source_id='C-CT5' and ph3.item_id=ix2.component_item_id and ph1.time_stamp>'2010-12-01 09:17:18.497'"
ThisWorkbook.Sheets(8).Cells(3, 1).CopyFromRecordset conn.Execute(sql) '
|
|