Hi there! I'm looking for advice/suggestions on how to approach a query that's going to be much more complex than I have previously had to deal with.
I have a web form where users can select from a number of possible search parameters (say, City, State, Zip Code, etc...) and pull a list of users from this database, and can select the specific data fields they want displayed as well. The complicated part is that the possible search parameters (and data to display) are spread out over several tables.
How should I go about tackling this little monster? If it's any help, I am using Visual Web Developer 2005 Express Edition and Microsoft ASP.NET Web Matrix to create this form.
Thanks a million,
Kaiti
This question has been answered a few times here. Search for "Dynamic Where" or "dynamic search". You can even limit it results to my posts as I remember participating in at least one such thread.
|||
string strSearchTerm ="comma delimited search terms";// use regular expressions to check for malicious entriesstring[] arrSearchTerms = strSearchTerm.split(',');StringBuilder sbCmd =new StringBuilder();for(int i = 0; i < arrSearchTerms.lenth; i++){if(i != 0) sbCmd.Append("or "); snCmd.Append("[Field] = " + arrSearchTerms[i] +" ");}SELECT FROM [Table1] join [Table2] on ... WHERE// ADD sbCmd.ToString here.
No comments:
Post a Comment