vendredi 30 janvier 2015

DataReader never enters Read()

Using Prism 5 (if that matters), I'm trying to read a table into a class but when I run the program the SQLiteDataReader Read() is never executed (or so I think since its Breakpoint is never hit).


Within my solution I have a ModuleA with a ViewModel class with a method that will update Bindings in the View:



public void ShowGeneral()
{
Personnel personnel = new Personnel();
personnel = PersonnelDAL.GetPersonnelRecord(Human);
pName = personnel.PersonName + " Esquire";
pAge = personnel.PersonAge;
}


PersonnelDAL.GetPersonnelRecord() is in a seperate Module. (This Module has References to SQLite).



public static Personnel GetPersonnelRecord(int id)
{
SQLiteConnection myDBconnection = new SQLiteConnection(SQLiteDAL.dbConnectionString);
Personnel personnel = new Personnel();

try
{
myDBconnection.Open();
string strQuery = "SELECT Person.*, Personnel.*," +
" FROM Person, Personnel WHERE Person.PersonPersonnelID = Personnel.PersonnelID AND Person.PersonID = @PersonID";
SQLiteCommand query = new SQLiteCommand(strQuery, myDBconnection);
query.Parameters.Add(new SQLiteParameter("@PersonID") { Value = id });
// A Breakpoint set here is hit
SQLiteDataReader myReader = query.ExecuteReader();

// A Breakpoint set here is never hit
while (myReader.Read())
{
personnel.PersonID = myReader.GetInt32(0);
personnel.PersonName = myReader.GetInt32(1);
personnel.PersonAge = myReader.GetInt32(3);

// etc


As a result the View displays no value for Age and only Esquire for name.


Why is myreader.Read() never executed?


Aucun commentaire:

Enregistrer un commentaire