How to avoid this kind of exception?
I have an sqlite database, and a table, in which i have a column PIN as a TEXT, and it's empty. when i'm getting it from the database, and trying to convert into a string it brings me an exception, When casting a number the value must be less then infinity...what is the reason?
In databases like sqlite, empty strings and null are two different things. It looks like you may be trying to cast your PIN to an int, or some other integer type. If the PIN field is null or DBNull, this cast will fail, giving the exception you listed. To further complicate things, null != DBNull.Value, which is what your database query is likely returning.
To check for this, you need to check the PIN field against DBNull.Value and cast only after you've checked.
See: DBNull Class