Hey bro.,
Please help me to save the checkbox value into access database.
below is my code to save one record.
Thanks,
vb kid
Please help me to save the checkbox value into access database.
below is my code to save one record.
Thanks,
vb kid
Code:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim cmd As New OleDb.OleDbCommand
If Not cnn.State = ConnectionState.Open Then
'open connection if it is not yet open
cnn.Open()
End If
cmd.Connection = cnn
'check whether add new or update
If Me.txtstdID.Tag & "" = "" Then
'add new
'add data to table
cmd.CommandText = "INSERT INTO student(stdid, stdname, gender, phone, address, salary, driving) " & _
" VALUES(" & Me.txtstdID.Text & ",'" & Me.txtStdName.Text & "','" & _
Me.cboGender.Text & "','" & Me.txtPhone.Text & "','" & _
Me.txtAddress.Text & "','" & Me.txtSalary.Text & "','" & Me.CheckBox1.Text & "')"
cmd.ExecuteNonQuery()
Else
'update data in table
cmd.CommandText = "UPDATE student " & _
" SET stdid=" & Me.txtstdID.Text & _
", stdname='" & Me.txtStdName.Text & "'" & _
", gender='" & Me.cboGender.Text & "'" & _
", phone='" & Me.txtPhone.Text & "'" & _
", address='" & Me.txtAddress.Text & "'" & _
", salary='" & Me.txtSalary.Text & "'" & _
", driving='" & Me.CheckBox1.Text & "'" & _
" WHERE stdid=" & Me.txtstdID.Tag
cmd.ExecuteNonQuery()
End If
'refresh data in list
RefreshData()
'clear form
Me.btnClear.PerformClick()
'close connection
cnn.Close()
End Sub