Last post Jun 22, 2015 03:31 PM by barricade823
May 23, 2007 01:38 PM|RyanSmith345|LINK
I'm looking for a way to pass an array of values as a parameter to a query in a table adapter. For example I want to run a query something like:
SELECT * FROM menu WHERE menu_role IN (@roles)
And I could pass something like 'RegisteredUser, SuperUser, OtherUser' to the @roles parameter.
For some reason I can't figure out a way to do this. Any help would be greatly appericated.
May 23, 2007 01:43 PM|satya_tanwar|LINK
This is possible from only code behind. Dynamically create the string and assrign it to the select command of tableadapter.
check this link
May 23, 2007 01:58 PM|RyanSmith345|LINK
May 23, 2007 02:05 PM|ndinakar|LINK
Check if this helps:
Jun 01, 2007 01:52 PM|WickedTribe|LINK
There's more than one way to skin a cat...
I was trying to figure out the same thing when I realized I could filter the data AFTER it was returned. I put it in a dataview and used the rowfilter property. Hope that helps!
Jun 01, 2007 03:59 PM|RyanSmith345|LINK
Jun 22, 2015 03:31 PM|barricade823|LINK
You're a genius. Thank you so much!
I did something along the lines of turning off all rows in the dataGridView and then turning them back on if the information I wanted to match was equal to any of the values in the array.
foreach (DataGridViewRow row in dataGridView1.Rows)
row.Visible = false;
for (int i = 0; i < sRelationArray.Length; i++)
if (sRelationArray[i] == row.Cells.Value.ToString())
row.Visible = true;