prdeshpande
asked on
how to run Distinct query on DataTable?
Hi, I have created DataTable “dt1” programmatically and enter query results in that datatable “dt1”.
Below is the code:
string strquery = "SELECT Name, Phones FROM Directory";
SqlCommand cmd = new SqlCommand(strquery, connection);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt1 = new DataTable();
da.Fill(dt1);
-------------------------- ---------- ---------- ---------- ---------- ---
Now, I want to run Distinct query on one of the column “Phone” or Name and result should get store in another datatable.
How it can be done?
Regards,
Below is the code:
string strquery = "SELECT Name, Phones FROM Directory";
SqlCommand cmd = new SqlCommand(strquery, connection);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt1 = new DataTable();
da.Fill(dt1);
--------------------------
Now, I want to run Distinct query on one of the column “Phone” or Name and result should get store in another datatable.
How it can be done?
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.