How to retrieve checked value of checkbox from sql server 2005 using C# on windows form
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Hemant KumarRank #1,202 · 1.5K reputationPosted Jun 29, 2012, 4:09 AM EDT
Dim query As String = "INSERT INTO TABLENAME (CheckBoxColumn) VALUES (@CheckBoxColumn)"
Dim conn As New SqlClient.SqlConnection("Connection String")
Dim cmd As New SqlClient.SqlCommand(query, conn)
If CheckBox1.Checked = True Then
cmd.Parameters.Add("@CheckBoxColumn", SqlDbType.Bit).Value = 1
Else
cmd.Parameters.Add("@CheckBoxColumn", SqlDbType.Bit).Value = 0
End If
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
You can get connection string from http://www.connectionstrings.com.