Posts
265
Comments
80
Trackbacks
4
Die Auswahl von Multiselect-Boxen im SQL berücksichtigen

Hier ein beispiel wie man die Auswahl von Multiselect-Boxen im SQL berücksichtigen kann.

Die kommaseparierte Auswahl sowie das Tabellenfeld wird an die Methode SplitSearchItems übergeben:

 public string SplitSearchItems( string Field, string Values)
{
   string searchItems = "";

   foreach( string s in Values.Split( ',' ) ) {
      searchItems += " AND " + Field + "=" + s.ToString();
   }

   return searchItems;
}

Beim Zusammenetzen des SQL-Strings kann man diese methode z.B. so verwenden:

if( Country.Length > 0 )
   where += SplitSearchItems( "Tabelle.Feld", Country );

posted on Tuesday, September 18, 2007 12:38 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 1 and 1 and type the answer here: