I am using SQLite C# library and as per my requirement, before going to add I am retreving the rowid of that table. It is working fine but hetting error when table is empty. Once we add any data(a row) then it’s working fine .
mDbCon = GetConnection();
SQLiteCommand cmd = mDbCon.CreateCommand();
cmd.CommandText = " SELECT MAX(rowid) FROM " + “MYTABLE”;
cmd.CommandType = CommandType.Text;
mDbCon.Open();
SQLiteDataReader sqReader = cmd.ExecuteReader();
while (sqReader.Read())
{
if ( sqReader.IsDBNull(0) )
{
max = (Int32)sqReader.GetInt32(0);
}
}
mDbCon.Close();
It’s throwing exception when table “MYTABLE” don’t have any data.