2014-06-05 2 views
-1
With rs 
    .CursorType = adOpenStatic 'I tried all types 
    .LockType = adLockOptimistic 'I tried all types 
    .CursorLocation = adUseClient 
    .Open com 
End With 

while rs.EOF = False 
    if val(t1.text) = rs.fields(1) then 
     msgbox "Reg.no. " & rs.fields(1) & " is Already in database" 
     'Our Searching work in db is done here, we want to close this while loop by code, so i used below 
     rs.EOF = True 'here compiler error gives "can't assign to read-only property" 
    else 
     rs.movenext 
    end if 
wend 

'here want to do " if not val(t1.text) = rs.fields(1) " operation 

Pls는 도움이rs.EOF = True 가능합니까? 어떤 조건이라면 vb6.0에서 가능합니까?

답변

3

아니 당신은 설정할 수 없습니다 rs.EOF = ... 그것은 PLS/'동안 루프를이 조건을 닫습니다 나에게 또 다른 솔루션을 알 수없는 경우,/쓰기 속성을 읽어 할당하려면 True는 읽기 전용 속성이므로 true이지만 루프에서 벗어날 수 있습니다. 다음과 같이 시도해보십시오.

Do while Not rs.EOF 
    if val(t1.text) = rs.fields(1) then 
     msgbox "Reg.no. " & rs.fields(1) & " is Already in database" 
     Exit Do 
    end if 
    rs.movenext 
Loop 
rs.close 
+0

고맙습니다 ... –