Jump to content
Sign in to follow this  
999ANDRE999

[Resolvido] Preencher checkbox pela BD

Recommended Posts

999ANDRE999

Boas pessoal,

Como faço para introduzir valores true/false de uma BD numa checkbox? 

Por exemplo, se na BD o valor for true, ao executar o codigo aparecer o pisco, se fosse false, nao aparecia nada.

Eu tentei com este codigo, mas dá erros:

comm.CommandText = " SELECT time_scheduling_closed FROM status_project where project = '" + search_project + "'";
CheckBox_time_scheduling = comm.ExecuteScalar();

e também tentei assim e nada:

comm.CommandText = " SELECT time_scheduling_closed FROM status_project where project = '" + search_project + "'";
CheckBox_time_scheduling.Checked = comm.ExecuteScalar();

Alguém consegue ajudar?

Share this post


Link to post
Share on other sites
apocsantos

Bom dia,

 

comm.CommandText = " SELECT time_scheduling_closed FROM status_project where project = '" + search_project + "'";
CheckBox_time_scheduling.checked = ((bool?)comm.ExecuteScalar()).GetValueOrDefault();

Cordiais cumprimentos,

Apocsantos

  • Vote 1

"A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito"

Share this post


Link to post
Share on other sites
999ANDRE999
15 minutos atrás, apocsantos disse:

Bom dia,

 


comm.CommandText = " SELECT time_scheduling_closed FROM status_project where project = '" + search_project + "'";
CheckBox_time_scheduling.checked = ((bool?)comm.ExecuteScalar()).GetValueOrDefault();

Cordiais cumprimentos,

Apocsantos

Obrigado amigo! :cheesygrin:

Resultou! :thumbsup:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.