Quote:
Conversion from type 'DBNull' to type 'String' is not valid.
That means the value coming from database is null. So you have to check if that is null or not before reading that.
txtgender.Text = If(IsDBNull(dr(2)), "", CStr(dr(2)))
I would also suggest two things here.
1. You should mention column names instead of * in the query.
2. Instead of index, read the column. Instead of
dr(2)
, you should read like
dr("Gender")
.