Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

saving checkbox value to database access in vb.net

$
0
0
I am using vb.net linked database access.
In the form i have 2 textbox as ID,Age and 2 Checkbox as HB,TC.
In the database i have similar columns as ID, Age, Hb,TC.

When i select one all the two checkboxes , they should be copied to respective column.
I have following code, but its not working properly.

If Hbtxt.Checked Then
cmd = New OleDbCommand("insert into Table1(ID,Age,Hb) values ('" & IDtxt.Text & "','" & Agetxt.Text & "','" & Hbtxt.Text& "')", con)
Else
cmd = New OleDbCommand("insert into Table1(ID,Age,Hb) values ('" & IDtxt.Text & "','" & Agetxt.Text & "','')", con)
End If
If TCtxt.Checked Then
cmd = New OleDbCommand("insert into Table1(ID,Age,TC) values ('" & IDtxt.Text & "','" & Agetxt.Text & "','" & TCtxt.Text& "')", con)
Else
cmd = New OleDbCommand("insert into Table1(ID,Age,TC) values ('" & IDtxt.Text & "','" & Agetxt.Text & "','')", con)
End If
cmd.ExecuteNonQuery()

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>