I have read countless exception examples on the web but i could not find "item not found exception " . Before it drives me nut, please hlp

It's an exception that comes out of automating windows powershell, usually generated when you tell it to use a specific file that doesn't exist.

i am sorry guys . I did my best but still i don't know how to throw "item not found"
exception when given item doesn't exist in the table.How can i improve the below code
which is ok

      try { 
  SQLiteConnection connection = gcnew SQLiteConnection();             
  connection.ConnectionString = "Data Source = atbdn3.db3";
  connection.Open(); 
  string selecteditem = (textBox1.Text).ToString();
  SQLiteCommand command = connection.CreateCommand();  
  command.CommandText ="select energy from table where product ='"+selecteditem +"'" ;     
    SQLiteDataReader dataReader = command.ExecuteReader();

    if (dataReader.HasRows == true)
    {
           while (dataReader.Read())
           {
              label1.Text = dataReader["energy_kcal"].ToString(); 
           }
     }

    else
    {
    MessageBox.Show("ITEM NOT FOUND.");  // item not found error i-m-i-t-a-tion ! 

    }

    connection.Close();

     }

    catch(Exception e )  {

     MessageBox.Show(e.Message) ;  // SQLite error : no such table

 }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Try this code, and let me know it the "file not found" message appears:

if (dataReader.Read())
    label1.Text = dataReader["energy_kcal"].ToString();
else
    MessageBox.Show("ITEM NOT FOUND."); // item not found error i-m-i-t-a-tion !

Mitja

yes bonca but you know what i want smt e.Message which equals item not found please

oh. You want an Exception message? You can only have Exception message on try, catch block (only on catch actually).
I doubt here is possible do it so. But you can write your own, like you did above; just write a messageBox with your own description.

This article has been dead for over six months. Start a new discussion instead.