stonezhang
June 13th, 2001, 11:39 AM
My code is like
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sSQL As String
'gSession.GetConn will open connection
Set conn = gSession.GetConn
For i = 1 To 12
strDateTo = frmChart.txtDate(4) & "/" & frmChart.txtDate(3) & "/" & frmChart.txtDate(5)
strDateFrom = frmChart.txtDate(1) & "/" & frmChart.txtDate(0) & "/" & frmChart.txtDate(2)
sSQL = "SELECT * FROM TestResult WHERE TestResult.Handset_Model = '" & strHandsetModel & "'"
sSQL = sSQL & " AND TestResult.Date_Time <= #"
sSQL = sSQL & strDateTo & "#"
sSQL = sSQL & " AND TestResult.Date_Time >= #"
sSQL = sSQL & strDateFrom & "#"
sSQL = sSQL & " AND Code = " & i
sSQL = sSQL & " ORDER BY Date_Time"
rs.Open sSQL, conn, adOpenStatic, adLockReadOnly
' If rs = Null Then Debug.Print "Good"
While Not rs.EOF
Debug.Print rs!Handset_Model, rs!Date_Time, rs!Code
'monthTestFrom = Month(dateTestFrom)
intMonth = (Month(rs!Date_Time) - Month(dateTestFrom)) + 1 + (Year(rs!Date_Time) - Year(dateTestFrom)) * 12
arrStat(intMonth, i + 1) = arrStat(intMonth, i + 1) + 1
rs.MoveNext
Wend
rs.Close
Next i
at first I want to compare rs.RecordCount to zero to decide if the recordset is null but seems does not work. Even there is nothing inside the recordset the RecordCount still = 1
if there is nothing in the rs, i will have prolem with my while loop. would u please tell me how to sort out this problem. email stone.zhang@one2one.co.uk
tks a lot
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sSQL As String
'gSession.GetConn will open connection
Set conn = gSession.GetConn
For i = 1 To 12
strDateTo = frmChart.txtDate(4) & "/" & frmChart.txtDate(3) & "/" & frmChart.txtDate(5)
strDateFrom = frmChart.txtDate(1) & "/" & frmChart.txtDate(0) & "/" & frmChart.txtDate(2)
sSQL = "SELECT * FROM TestResult WHERE TestResult.Handset_Model = '" & strHandsetModel & "'"
sSQL = sSQL & " AND TestResult.Date_Time <= #"
sSQL = sSQL & strDateTo & "#"
sSQL = sSQL & " AND TestResult.Date_Time >= #"
sSQL = sSQL & strDateFrom & "#"
sSQL = sSQL & " AND Code = " & i
sSQL = sSQL & " ORDER BY Date_Time"
rs.Open sSQL, conn, adOpenStatic, adLockReadOnly
' If rs = Null Then Debug.Print "Good"
While Not rs.EOF
Debug.Print rs!Handset_Model, rs!Date_Time, rs!Code
'monthTestFrom = Month(dateTestFrom)
intMonth = (Month(rs!Date_Time) - Month(dateTestFrom)) + 1 + (Year(rs!Date_Time) - Year(dateTestFrom)) * 12
arrStat(intMonth, i + 1) = arrStat(intMonth, i + 1) + 1
rs.MoveNext
Wend
rs.Close
Next i
at first I want to compare rs.RecordCount to zero to decide if the recordset is null but seems does not work. Even there is nothing inside the recordset the RecordCount still = 1
if there is nothing in the rs, i will have prolem with my while loop. would u please tell me how to sort out this problem. email stone.zhang@one2one.co.uk
tks a lot