Hi smile,
You need to check condition using where clause refer below sample.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Namespaces
C#
using System.Data.SqlClient;
VB.Net
Imports System.Data.SqlClient
Code
C#
private void Form1_Load(object sender, EventArgs e)
{
    string constr = "Server=.;DataBase=Northwind;UID=sa;PWD=123";
    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand("SELECT TOP 5 CompanyName, ContactName, Phone FROM Customers WHERE LEN(Phone) = 12", con))
        {
            using (SqlDataAdapter da = new SqlDataAdapter(cmd))
            {
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
        }
    }
}
VB.Net
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handle Me.Load
    Dim constr As String = "Server=.;DataBase=Northwind;UID=sa;PWD=123"
    Using con As SqlConnection = New SqlConnection(constr)
        Using cmd As SqlCommand = New SqlCommand("SELECT TOP 5 CompanyName, ContactName, Phone FROM Customers WHERE LEN(Phone) = 12", con)
            Using da As SqlDataAdapter = New SqlDataAdapter(cmd)
                Dim dt As DataTable = New DataTable()
                da.Fill(dt)
                dataGridView1.DataSource = dt
            End Using
        End Using
    End Using
End Sub
Screenshot
