Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

vb.net - How to save checkbox value into Access?

i have vb.net Applicationt contains Year months as Checkbox. I have following code to these items, the checkbox items is saved months into Access correctly, but when i return to the interface the checkbox aren't showing who's checked . So what to do?

''' Dim janvier As String Dim fevrier As String Dim mars As String Dim avril As String Dim mai As String Dim jui As String Dim juil As String Dim aout As String Dim sept As String Dim octo As String Dim nov As String Dim decem As String

    If ch_jan.Checked Then

        janvier = ch_jan.Text
        janvier = "valide"
    Else
        janvier = "<------>"
    End If


    If ch_fev.Checked Then
        fevrier = ch_fev.Text
        fevrier = "valide"
    Else
        fevrier = "<------>"
    End If

    If ch_mar.Checked Then
        mars = ch_mar.Text
        mars = "valide"
    Else
        mars = "<------>"
    End If

    If ch_apr.Checked Then
        avril = ch_apr.Text
        avril = "valide"
    Else
        avril = "<------>"
    End If

    If ch_mai.Checked Then
        mai = ch_apr.Text
        mai = "valide"
    Else
        mai = "<------>"
    End If

    If ch_jui.Checked Then
        jui = ch_jui.Text
        jui = "valide"
    Else
        jui = "<------>"
    End If

    If ch_juil.Checked Then
        juil = ch_juil.Text
        juil = "valide"
    Else
        juil = "<------>"
    End If

    If ch_aou.Checked Then
        aout = ch_aou.Text
        aout = "valide"
    Else
        aout = "<------>"
    End If

    If ch_sept.Checked Then
        sept = ch_sept.Text
        sept = "valide"
    Else
        sept = "<------>"
    End If

    If ch_oct.Checked Then
        octo = ch_oct.Text
        octo = "valide"
    Else
        octo = "<------>"
    End If

    If ch_nov.Checked Then
        nov = ch_nov.Text
        nov = "valide"
    Else
        nov = "<------>"
    End If

    If ch_dec.Checked Then
        decem = ch_dec.Text
        decem = "valide"
    Else
        decem = "<------>"
    End If


    Dim dtadapter As New OleDbDataAdapter(SQL_Adherent, MaConnection)
    savinto.Connection = MaConnection
    savinto.CommandType = CommandType.Text
    savinto.CommandText = "INSERT INTO Adherent(code_adh, nom, prenom, sexe, date_entrer, Photo,duree,rest,jan,fev,mar,avr,mai,jui,juil,out,sep,oct,nov,decem)" & " Values ('" & (txt_code_adh.Text) & "','" & txt_nom_adh.Text & "','" & txt_prenom_adh.Text & "','" & cmb_sexe.Text & "', '" & txt_date_entrer.Text & "','" & txt_lien_photo.Text & "','" & cmb_duree.Text & "','" & txt_rest.Text & "','" & janvier & "','" & fevrier & "','" & mars & "','" & avril & "','" & mai & "','" & jui & "','" & juil & "','" & aout & "','" & sept & "','" & octo & "','" & nov & "','" & decem & "')"
    MaConnection.Open()
    savinto.ExecuteNonQuery()
    dtset.Clear()
    dtadapter.Fill(dtset, "Adherent")
    MaConnection.Close()
    MsgBox(" Votre nouveau Adherent est bien Enregistrer")

End Sub

'''

question from:https://stackoverflow.com/questions/65945520/how-to-save-checkbox-value-into-access

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...