Solution 1 (RowFilter)
Dim ds As New Data.DataSetDim CN As New SqlClient.SqlConnection(MyClass1.ConnStr)
Dim Stmt As String
Stmt = "select * from USER_MASTER"
Dim DA As New SqlClient.SqlDataAdapter(stmt, CN)
DA.Fill(ds, "USER_MASTER")
ds.Tables("USER_MASTER").DefaultView.RowFilter = "DEPT ='ADMIN'"
MsgBox(ds.Tables("USER_MASTER").DefaultView.Count)
Solution 2 (Select)
Dim ds As New Data.DataSetDim CN As New SqlClient.SqlConnection(MyClass1.ConnStr)
Dim Stmt As String
Stmt = "select * from USER_MASTER"
Dim DA As New SqlClient.SqlDataAdapter(stmt, CN)
DA.Fill(ds, "USER_MASTER")
Dim R() As DataRow
R = ds.Tables("USER_MASTER").Select("DEPT ='ADMIN'", "EMP_NAME")
If R.Length > 0 Then
MsgBox(R.Length & " Record(s) Found")
End If
In the sample code it shows the number of records found for dept called "ADMIN",
No comments:
Post a Comment