Hi,
There has been a doubt on DataTable.Select method.
I do not get an expected result when i query a datatable, if there is an 'AND' condition, i do not get a resultant data back into rows again.
The code i have done is

                        // clone to get the structure copied.
                        dtTopologyActive = dtTopologyDevices.Clone();
                        string strSelect = "DeviceId =" + int.Parse(strDevId) + " AND Feederstatus not in (" + strFeedStat + ")";
                      // drActiveDevices the datarow[] 
                        drActiveDevices = dtTopologyDevices.Select(strSelect);
                        foreach (DataRow row in drActiveDevices)
                        {
                            dtTopologyActive.ImportRow(row);
                        }
                      // removing the rest of the entries for a particular device.
                        drAct = dtTopologyDevices.Select("DeviceId =" + int.Parse(strDevId));// AND Feederstatus in (" + strFeedStat + ")");
                        for (int i = 0; i < drAct.Length; i++)
                        {
                            dtTopologyDevices.Rows[i].Delete();
                            dtTopologyDevices.AcceptChanges();
                        }
                      // Adding the datarow (required) back to the main datatable.
                        foreach (DataRow row in dtTopologyActive.Rows)
                        {
                            dtTopologyDevices.ImportRow(row);
                        }

Please find the attachments.

Datatable_after_query

Thanks for help.

Mate,
tell us what EXACTLY IS that you want from the filering. Select query is doing EXACTLY what you tell it. And it does 100% fine.
The problem is only in your string.

To blindly guess what do you need is:

string strSelect = string.Format("DeviceId = '{0}' AND Feederstatus <>'{1}'", int.Parse(strDevId), strFeedStat);

<> means IS NOT equal.

Is there something else you want to use Feederstatus field?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.