TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aalhussein
1.6k
133
10k
how to pull bool datatype field in db into a checkbox property
Dec 17 2020 5:47 AM
I am pulling data from database to a datareader object "dr"
once I iterate throught the dr, I need to pull its value to a variable :
bool profileComplete = dr["profileComplete"] // this caused error stating that cannot implicitely convert type 'object' to a bool .
My question, why when I use bool.Parse, in code below, shows a message " cannot convert from object to a string "
profileComplete = bool.Parse(dr["profileComplete"]
However, when I add .ToString() it works:
profileComplete = bool.Parse(dr["profileComplete"].ToString());
By the way, the datatype of profileComplete in the database is bit ( 0,1 )
// this is what I need to do , to populate a checkbox with a value from db
cbProbileComplete.Checked = profileComplete ;
Reply
Answers (
2
)
Get Data Using API.
how to capture bit database column field into a checkbox property