- Katılım
- 14 Ocak 2005
- Mesajlar
- 807
- Excel Vers. ve Dili
- Microsoft Office Professional Plus 2021
Selamlar,
Aşağıdaki kodla sqlserverden 36885 satırlık veri çekmem gerekiyor excelden 29665 satır veri çekiyorum sorun yok ama bütün kriterlerimi girince toplam sqlden getirmesi gereken satır sayısı 36885 oluyor ve runtime error '6': ve OverFlow hatası veriyor sebebi ne olabilir, nasıl çözebiliriz. Bütün kriterlerimi tek tek deneyince sorunsuz alınıyor. hepsini bir alınca bu hatayı veriyor.
Aşağıdaki kodla sqlserverden 36885 satırlık veri çekmem gerekiyor excelden 29665 satır veri çekiyorum sorun yok ama bütün kriterlerimi girince toplam sqlden getirmesi gereken satır sayısı 36885 oluyor ve runtime error '6': ve OverFlow hatası veriyor sebebi ne olabilir, nasıl çözebiliriz. Bütün kriterlerimi tek tek deneyince sorunsuz alınıyor. hepsini bir alınca bu hatayı veriyor.
Kod:
'UYGUNSUZ ÜRÜN GEL
Dim BASTAR As String
Dim BITTAR As String
Dim BSYIL As String
Dim BSAY As String
Dim BSGUN As String
Dim BTYIL As String
Dim BTAY As String
Dim BTGUN As String
Dim bar As String
Dim DEPARTMAN As String
Dim SATISTIP As String
Dim SQLText As String
Dim I As Integer
Dim RST As New ADODB.Recordset
Call Main
DoEvents
SQLCON.Open
BSYIL = Range("B3")
BSAY = Range("C3")
BSGUN = Range("D3")
BTYIL = Range("B4")
BTAY = Range("C4")
BTGUN = Range("D4")
BASTAR = BSYIL + " - " + BSAY + " - " + BSGUN
BITTAR = BTYIL + " - " + BTAY + " - " + BTGUN
DEPARTMAN = Range("F3")
SATISTIP = Range("F4")
bar = ""
REST = ""
Havuz = ""
MiniBar = ""
Plaj = ""
Market = ""
Cafe = ""
If CheckBox1.Value = True Then
bar = "11"
End If
If CheckBox2.Value = True Then
REST = "12"
End If
If CheckBox3.Value = True Then
Havuz = "15"
End If
If CheckBox4.Value = True Then
MiniBar = "16"
End If
If CheckBox5.Value = True Then
Plaj = "14"
End If
If CheckBox6.Value = True Then
Market = "38"
End If
If CheckBox7.Value = True Then
Cafe = "19"
End If
If CheckBox8.Value = True Then
bar = "11"
REST = "12"
Havuz = "15"
MiniBar = "16"
Plaj = "14"
Market = "38"
Cafe = "19"
End If
SQLText = "SELECT TABLO_TAR, TABLO_FOLIO, TABLO_ODA_NUM, TABLO_JOIN_REFNO," & vbCrLf
SQLText = SQLText & " TABLO-2_DEP, SUM(TABLO_NET_TLL)AS TABLO_TUT, " & vbCrLf
SQLText = SQLText & " AVG(TABLO-2_NET_TLL) AS ADISYON_TUT FROM TABLO " & vbCrLf
SQLText = SQLText & " JOIN TABLO-2 ON(TABLO-2_RECNO = TABLO_JOIN_REFNO) " & vbCrLf
SQLText = SQLText & " WHERE " & vbCrLf
SQLText = SQLText & " TABLO_TAR BETWEEN '" + BASTAR + "' AND '" + BITTAR + "' AND " & vbCrLf
SQLText = SQLText & " TABLO_ODA_NUM = '" + SATISTIP + "' AND " & vbCrLf
SQLText = SQLText & " TABLO-2_DEP IN ('" + bar + "','" + REST + "','" + Havuz + "','" + MiniBar + "','" + Plaj + "','" + Market + "','" + Cafe + "') AND" & vbCrLf
','" + Havuz + "','" + MiniBar + "','" + Plaj + "','" + Market + "','" + Cafe + "'
SQLText = SQLText & " TABLO_JOIN_TABLE = 'TABLO-3' " & vbCrLf
SQLText = SQLText & " GROUP BY TABLO_TAR, TABLO_FOLIO, TABLO_ODA_NUM, TABLO_JOIN_REFNO, TABLO-2_DEP " & vbCrLf
SQLText = SQLText & " ORDER BY TABLO_JOIN_REFNO " & vbCrLf
'SQLText = SQLText & " TABLO_DEP = '" + DEPARTMAN + "' AND " & vbCrLf
'SQLText = SQLText & " TABLO_ODA_NUM = '" + SATISTIP + "' AND " & vbCrLf
'SQLText = SQLText & " TABLO_TAR BETWEEN '" + BASTAR + "' AND '" + BITTAR + "' " & vbCrLf
'
Set RST.DataSource = SQLCON.Execute(SQLText)
Range("A13:K25000").Select
Selection.ClearContents
Do Until RST.EOF
For I = 1 To RST.RecordCount Step 1
Application.StatusBar = "Tamamlanan : " & Int(I / RST.RecordCount * 100)
Cells(I + 12, 1) = RST.Fields(0)
Cells(I + 12, 2) = RST.Fields(1)
Cells(I + 12, 3) = RST.Fields(2)
Cells(I + 12, 4) = RST.Fields(3)
Cells(I + 12, 5) = RST.Fields(4)
Cells(I + 12, 6) = RST.Fields(5)
Cells(I + 12, 7) = RST.Fields(6)
'Cells(I + 12, 8) = RST.Fields(7)
'Cells(I + 12, 9) = RST.Fields(8)
'Cells(I + 12, 10) = RST.Fields(9)
'Cells(I + 12, 11) = RST.Fields(10)
'Cells(I + 12, 12) = RST.Fields(11)
'Cells(I + 12, 13) = RST.Fields(12)
'Cells(I + 12, 14) = RST.Fields(13)
'Cells(I + 12, 15) = RST.Fields(14)
'Cells(I + 12, 16) = RST.Fields(15)
'Label1.Caption = "% " & Round(I / RST.RecordCount * 100, 0)
RST.MoveNext
Next I
Loop
RST.Close
SQLCON.Close
Range("B4").Select
MsgBox "Rapor Bitti. ***Bu liste ÖZCAN ÖZARSLAN tarafından 11/03/2008 tarihinde geliştirilmiştir.***"
End Sub
