Beispiel #1
0
        // get language ID based on language name
        public static int GetLID(string languageName)
        {
            int lID = -1;

            MediaDataSet.TabLanguageDataTable tabLanguageDataTable    = new MediaDataSet.TabLanguageDataTable();
            TabLanguageTableAdapter           tabLanguageTableAdapter = new TabLanguageTableAdapter();

            try
            {
                // retrieve data from database
                tabLanguageTableAdapter.SelectLanguage(tabLanguageDataTable, languageName);

                // convert data into int
                lID = (int)tabLanguageDataTable.Rows[0]["LID"];
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(languageName + " cannot be found in the database.");
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(lID);
        }