So I have this problem - I want to allow users of my app to run select queries against a PostgreSql database and I want the data returned by those queries to be bound to a DataSet
-> DataGrid
. Problem is the "custom" part :). Of course when I try to edit data coming from a query with join clause, then the trouble starts. I'm getting an error saying that UpdateCommand
couldn't be automatically generated because of lacking primary key column, which is expected (well, at least I was expecting it)... Solution I came up with is primitive, but good enough for me - I have a list of table names, and when one of those table names is found in custom query, then I want to generate my own UpdateCommand
on the fly. So:
- I'm having trouble writing regular expression that would get table names from query, so any help would be much appreciated :). Thing is tricky - you've got to remember that table name may also be found as a column name, so the regular expression should be able to filter out that cases.
- Is it generally a good idea in my scenario? Maybe there's a simpler and/or more elegant solution to my problem?
Something like a pseudo code:
string[] names = new string[] { "table1", "table2" };
string customQuery = GetWhateverUserWroteInATextBox();
//what I want to do is to find name coming from names array in the customQuery
I'm calling it a custom query, because the user writes it, and I can't predict what the user input will be.