'Recordset偐傜僙儖揬傝晅偗梡偺2師尦攝楍傪嶌惉
'varchar(max)偺僼傿乕儖僪懳墳斉
Dim recArray() As Variant '2師尦攝楍(楍丄峴)
Dim recIdx As Long '峴曽岦偺揧帤
Dim fieldIdx As Integer '楍曽岦偺揧帤
Dim unicodeString As String
Do Until dbConn.recordset.EOF
If recIdx >= getSelectMaxValue Then
Exit Do
End If
ReDim Preserve recArray(dbConn.recordset.Fields.Count - 1, recIdx)
For fieldIdx = 0 To dbConn.recordset.Fields.Count - 1
unicodeString = getOriginalUnicodeString2(dbConn.recordset.Fields(fieldIdx))
' recArray(fieldIdx, recIdx) = unicodeString
recArray(fieldIdx, recIdx) = left(unicodeString, 1020)
Next
recIdx = recIdx + 1
dbConn.recordset.movenext
Loop
getRecordArray = recArray
End Function
Public Function setSelectedData(dbConn As DbConnection, connInfo As ConnectInfo, _
calledFrom As String, dtSht As DataSheetInfo, flatSql As String, _
orgSql As String, pageCnt As Integer, newStartRow As Long) As Boolean
'Recordset偺僨乕僞傪僔乕僩偵僙僢僩偡傞丅
Application.ScreenUpdating = False
Dim newEndRow As Long '怴偨偵庢摼偟偨僨乕僞偺弌椡廔椆峴
'Recordset偐傜僙儖揬傝晅偗梡偺2師尦攝楍傪嶌惉
Dim recordArray() As Variant '僙儖揬傝晅偗梡偺2師尦攝楍(楍, 峴)
recordArray = getRecordArray(dbConn, newStartRow)
Dim firstCol As Integer
If dtSht.isQuerySheet Then
firstCol = dtSht.firstCol
Else
firstCol = 3
End If
'僙儖偵揬傝晅偗
Dim endCol As Integer
newEndRow = newStartRow + UBound(recordArray, 2)
endCol = firstCol + UBound(recordArray, 1)
On Error GoTo errHandler:
If calledFrom = "FreeSQL" Then
Call formatForFreeSQL(dbConn, dtSht, newStartRow, newEndRow, firstCol) 'FreeSQL梡偺彂幃愝掕
Range(Cells(newStartRow, firstCol), Cells(newEndRow, endCol)) = Application.WorksheetFunction.Transpose(recordArray)
Else
Range(Cells(newStartRow, firstCol), Cells(newEndRow, endCol)) = Application.WorksheetFunction.Transpose(recordArray)
Call formatForDataSheet(dbConn, dtSht, newStartRow, newEndRow) 'SELECT儃僞儞梡偺彂幃愝掕
End If
Call setRowHeaderToNewData(connInfo, calledFrom, newStartRow, newEndRow, pageCnt, firstCol, dtSht) '峴僿僢僟乕
'僨乕僞弌椡峴偑夋柺偺昞帵斖埻撪偱側偗傟偽丄奩摉峴偵僗僋儘乕儖偡傞
If ActiveWindow.VisibleRange.Row < newStartRow And _
newStartRow < ActiveWindow.VisibleRange.Row + ActiveWindow.VisibleRange.Rows.Count Then
Else
If calledFrom = "FreeSQL" Then
Application.GoTo Cells(newStartRow - 2, 1), True
Else
Application.GoTo Cells(newStartRow - 1, 1), True
End If
End If
Cells(newStartRow, 1).Select
Application.ScreenUpdating = True
newStartRow = newEndRow + 1 '師偺儁乕僕偺愭摢峴
Exit Function
errHandler:
If Err.Number = 7 Or Err.Number = 1004 Then
Err.Raise vbObjectError + 513, , "僄儔乕丅Excel偺惂尷傪挻偊偰偄傞壜擻惈偑偁傝傑偡丅" & vbNewLine & _
"徻偟偔偼僿儖僾僼傽僀儖偺乽惂尷乿傑偨偼乽婛抦偺晄嬶崌乿傪嶲徠偟偰壓偝偄丅"
Else
Err.Raise Err.Number, , Err.Description
End If
End Function