c# - Data exists but my program says 'No data exists for the row/column.' -


    private void recordfromtable()     {         string firstname = environment.username.split('.')[0];         string lastname = environment.username.split('.')[1];         string query = "select lastupdate " + "employeecontact" + " employeelastname='" + lastname + "' , employeefirstname='" + firstname + "'";         try         {             using (oledbconnection connection = new oledbconnection(connectionstring))             {                 oledbcommand command = new oledbcommand(query, connection);                 connection.open();                 using (oledbdatareader reader = command.executereader())                 {                     while (reader.read())                     {                         labellastupdated.text = reader.getstring(0).trim();                     }                 }             }         } catch (exception ex)         {             console.writeline(ex.message);         }     } 

the exception thrown no data exists row/column.

i opened access database , ran same query (that inspector showed while debugging) , row database.

all fields in access "short text"

if you're sure data exists, seems me firstname or lastname variables may not getting assigned values believe or want them to.


Comments