Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

right syntax for storing a checkbox value 2

Status
Not open for further replies.

dinster

Programmer
Apr 12, 2007
54
GB
Hi all am currently saving data using an aspx webpage. I can store textbox values but having trouble getting the syntax right for a checkbox value....

could any1 have look at this code and see where am going wrong?

Code:
cmd.Parameters.Add(New OleDbParameter("@Location", txt_Location.text))
	cmd.Parameters.Add(New OleDbParameter("@Diagnosis", txt_Diagnosis.text))
	
[COLOR=#ff0000]
	If chk_sepsit.Checked Then
	cmd.Parameters.Add(New OleDbParameter("@SurvingSepsis", chk_sepsit.value = True))
	else
	cmd.Parameters.Add(New OleDbParameter("@SurvingSepsis", chk_sepsit.value = False))
	end if
[/color]
 
You don't have to check if it is checked or not, just assign the value based on it's Checked property e.g
Code:
cmd.Parameters.Add(New OleDbParameter("@SurvingSepsis", chk_sepsit.Checked))



-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Remove the "= TRUE" and the "= False "
and replace with chk_sepsit.checked
 
cheers guys...you made that look so simple! lol
 
glad to help .. you'll get the hang of .NET. Just keep plugging away..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top