SQLITE problem in rowid
Posted
by Saurabh
on Stack Overflow
See other posts from Stack Overflow
or by Saurabh
Published on 2010-04-01T05:50:58Z
Indexed on
2010/04/01
5:53 UTC
Read the original article
Hit count: 513
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.
© Stack Overflow or respective owner