Click here to Skip to main content
15,668,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have head hunting problem with the below codes...Really it tooks my holeday, but still not clear... Any superiors can help me to clear?
Thanks

My Codes
MyDtb1 = MyOriginalDtb;
DataView MyDtbView = MyDtb1.DefaultView;
MyDtbView.Sort = "prn_no,sheet_no,prn_date,pty_name";
MyDtbView.RowFilter = nullptr;
//MyDtbView.RowFilter = "prn_status<>'CLOSED'";  ?????????????????


From the above code DataView RowFilter is not showing all rows, means it omits the last rows.. And hence I achieved by the following code has working good....
for (int T2 = 0; T2 <= MyDtbView.Count-1; T2++) {
  if (Convert.ToString(MyDtbView[T2]["prn_status"].ToString()) != "CLOSED") {
// Good and not skipped any rows
  }
}

Thanks for the helps

What I have tried:

DataView RowFilter by <> [Not Equal] Operator
Posted
Updated 7-Jan-20 20:09pm

1 solution

It works for me:
C#
string strConnect = SMDBSupport.SMInstanceStorage.GetInstanceConnectionString("VideoMaster");
using (SqlConnection con = new SqlConnection(strConnect))
    {
    try
        {
        con.Open();
        using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM TVShows WHERE Title LIKE '%' + @SEARCH +'%'", con))
            {
            da.SelectCommand.Parameters.AddWithValue("@SEARCH", "Expanse");
            using (DataTable dt = new DataTable())
                {
                da.Fill(dt);
                DataView dv = new DataView(dt);
                myDataGridView.DataSource = dv;
                dv.RowFilter = "Title <> 'The Expanse S04E01 New Terra'";
                }
            }
        }
    catch (Exception ex)
        {
        Debug.WriteLine(ex.ToString());
        }
    }
 
Share this answer
 
Comments
Paramu1973 8-Jan-20 2:29am    
Thanks. But have you tried other than sql connection? looking from the datatable row filter...Thank again
OriginalGriff 8-Jan-20 3:18am    
You do realise that the SQLConnection just fills the DataTable, the actual data source is completely irrelevant from then on?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900