can someone please tell me how to fix this thing? Im loosing my mind here. in a form this code work well. in other it doesn't
I create an other form, import everything again and it is not working!

   try{
            int row = Data_Table1.getSelectedRow();
            String Table_click1 =(Data_Table1.getModel().getValueAt(row, 0).toString());

            String sql = "SELECT * FROM BatchFiles where InvoiceNumber= '"+Table_click1+"'";

            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();


             if(rs.next()){

            String add1 = rs.getString("InvoiceNumber");
            Date.setText(add1);


        }



      }catch(Exception e){
      JOptionPane.showMessageDialog(null, e);
      }finally{
            try{
             rs.close();
             pst.close();                
            }
              catch(Exception e){        
                                }    

            }

it doesn't execute this code

                 if(rs.next()){

                String add1 = rs.getString("InvoiceNumber");
                Date.setText(add1);

does someone know how to fix this thing?

add an else block, see if if ( rs.next()) actually returns true.
Also, check the value of variable Table_click1 .
For all we know your query just doesn't return any results.

Just a few more recommendations:

catch(Exception e){     }

avoid doing this: at least log the error.

Start following naming conventions. It'll make it easier for other people to read your code.

Date for me is either java.util.Date, or java.sql.Date, but not a variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.