Ave populus,
in una macro excel eseguo una query ad as400, ma la query tira fuori troppi dati, e l'applicativo vā in buffer overflow, fermando l'esecuzione della macro
Il codice della macro in questione č questo:
P.S. le linee spezzate sono per esigenze di layout del forumcodice:Option Explicit Const INIZIO As Integer = 2 Sub estrai() Dim conn As Connection, CellaAtt As Range Dim rs As ADODB.Recordset, cmd As ADODB.Command, str As String Dim sql As String, i As Integer, data1 As String, data2 As String Set conn = CreateObject("ADODB.connection") str = "Driver={Client Access ODBC Driver (32-bit)}; Server=192.168.xxx.xxx; Uid=user; Pwd=xxx; System=S44A3312;" conn.Open str Set cmd = CreateObject("ADODB.Command") Set cmd.ActiveConnection = conn cmd.CommandType = adCmdText sql = "select CART,CARV,XART, CSTA, CATG, CATS from MERSY_DB.arasso0f where catg='GV' AND CATS ='01' order by cart, carv" cmd.CommandText = sql 'ActiveSheet.Cells(1, 5) = (sql) Set rs = cmd.Execute() i = INIZIO While Not rs.EOF() ActiveSheet.Cells(i, 1) = rs(0) ActiveSheet.Cells(i, 2) = rs(1) ActiveSheet.Cells(i, 3) = rs(2) ActiveSheet.Cells(i, 4) = rs(3) ActiveSheet.Cells(i, 5) = rs(4) ActiveSheet.Cells(i, 6) = rs(5) rs.MoveNext i = i + 1 Wend rs.Close Set rs = Nothing conn.Close Set conn = Nothing MsgBox ("Estrazione conclusa") End Sub

Rispondi quotando