String a;
For (int I=0, i<10, i++) {
If (item (I)!={strState)
{if (strCountry="CH")
A="kk";
} else {
A="";
}
} else {
A="";
}
}
With vb to achieve
The great god for help
CodePudding user response:
BOF, EOF and Bookmark property example
The example USES a BOF and EOF attributes in a user attempts to move through you first and the last record, display a message, it through the Bookmark property users to record of you, back to it later,
Public Sub BOFX ()
Dim rstPublishers As ADODB. You
Dim strCnn As String
Dim strMessage As String
Dim intCommand As Integer
Dim varBookmark As the Variant
'using the data from the publishers table open recordset,
StrCnn="Provider=sqloledb;" & _
"Data Source=the SRV; Initial Catalog=pubs; User Id=sa; Password=; "
The Set rstPublishers=New ADODB. You
RstPublishers. CursorType=adOpenStatic
'using client-side cursor enable AbsolutePosition properties,
RstPublishers. CursorLocation=adUseClient
RstPublishers. Open the "SELECT pub_id, pub_name FROM publishers" & amp; _
"The ORDER BY pub_name," strCnn,,, adCmdText
RstPublishers. MoveFirst
The Do While True
'display information about the current record and let user input,
StrMessage="Publisher:" & amp; RstPublishers! Pub_name & amp; _
VbCr & amp; "(record" & amp; RstPublishers. AbsolutePosition & amp; _
"Of" & amp; RstPublishers. RecordCount & amp; ") "& amp; VbCr & amp; VbCr & amp; _
"Enter the command:" & amp; VbCr & amp; _
"[1-2 - previous/next/" & amp; vbCr & amp; _
"3 - set a bookmark/4 - go to a bookmark]"
IntCommand=Val (InputBox (strMessage))
The Select Case intCommand
'move forward or backward, capture BOF or EOF,
Case 1
RstPublishers. MoveNext
If rstPublishers. EOF Then
MsgBox "Moving past the last record." & amp; _
VbCr & amp; "Try again."
RstPublishers. MoveLast
End the If
Case 2
RstPublishers. MovePrevious
If rstPublishers. BOF Then
MsgBox "Moving past the first record." & amp; _
VbCr & amp; "Try again."
RstPublishers. MoveFirst
End the If
'to save the current record of bookmarks,
Case 3
VarBookmark=rstPublishers. Bookmark
'turn to the records of bookmarks indicated by the store,
Case 4
If IsEmpty (varBookmark) Then
MsgBox "No Bookmark set!"
The Else
RstPublishers. Bookmark=varBookmark
End the If
In Case the Else
The Exit Do
End the Select
Loop
RstPublishers. Close
End Sub
This example USES a Bookmark and Filter property creation of limited view of the record set, will only allow access to Bookmark array references,
Public Sub BOFX2 ()
Dim the rs As New ADODB. You
Dim BMK (10)
Rs. CursorLocation=adUseClient
Rs. The ActiveConnection="Provider=sqloledb;" & _
"Data Source=the SRV; Initial Catalog=pubs; User Id=sa; Password=;"
Rs. Open the "select * from the authors,", adOpenStatic, adLockBatchOptimistic
The Debug. Print "Number of records before filtering:", rs. RecordCount
Ii=0
EOF & lt; While the rs.> True And ii & lt; 11.
BMK (ii)=rs. Bookmark
2=2 + 1
Rs. Move 2
Wend
Rs. The Filter=BMK
The Debug. Print "Number of records after filtering:", rs. RecordCount
Rs. MoveFirst
EOF & lt; While the rs.> True
The Debug. Print rs. AbsolutePosition, rs (" au_lname ")
Rs. MoveNext
Wend
End Sub
CodePudding user response:
sample Count property
This example USES the employee database in two set Count property, the property For Each number and the enumeration of these collections of objects in the collection cycle cap, another is not through the use of the Count property to enumeration method is used For Each of these collections... The Next statement,
Public Sub CountX ()
Dim rstEmployees As ADODB. You
Dim strCnn As String
Dim intloop As Integer
Employees' use of the data in the table to open the recordset,
StrCnn="Provider=sqloledb;" & _
"Data Source=the SRV; Initial Catalog=pubs; User Id=sa; Password=; "
The Set rstEmployees=New ADODB. You
RstEmployees. Open "employee," strCnn,,, adCmdTable
'print information about field collection,
The Debug. Print rstEmployees. Fields. Count & amp; _
"Fields in the Employee
"For intloop=0 To rstEmployees. Fields. The Count - 1
The Debug. Print "" & amp; RstEmployees. Fields (intloop). The Name
Next intloop
'print attribute collection information,
The Debug. Print rstEmployees. Properties. Count & amp; _
"The Properties in the Employee
"For intloop=0 To rstEmployees. Properties. The Count - 1
The Debug. Print "" & amp; RstEmployees. The Properties (intloop). The Name
Next intloop
RstEmployees. Close
End Sub
CodePudding user response:
It isn't necessary, SQL query add a Where clause is ok,CodePudding user response:
Even for you, also can use the Filter property of information filtering,CodePudding user response:
Use ole is very convenient