我的GUI中有两个单选按钮(男性和女性)。我想要的是必须将所选按钮插入/添加到我的数据库中,但我似乎无法弄明白。有人可以帮忙吗?
Private Sub add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles add.Click
If PersonnelID.Text = "" And Fname.Text = "" And Mname.Text = "" And Lname.Text = "" And Address.Text = "" Then
MsgBox("Please fill all the fields", MsgBoxStyle.OkOnly, "Error!")
Else
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\faculty.mdb;")
cn.Open()
Me.sql = "SELECT * FROM Personnel"
Me.da = New OleDb.OleDbDataAdapter(Me.sql, cn)
Me.da.Fill(Me.ds, "faculty")
Me.maxrows = Me.ds.Tables("faculty").Rows.Count
Dim cb As New OleDbCommandBuilder(da)
Me.dsNewRow = Me.ds.Tables("faculty").NewRow
Me.dsNewRow.Item("PersonnelID") = Me.PersonnelID.Text
Me.dsNewRow.Item("FirstName") = Me.Fname.Text
Me.dsNewRow.Item("MiddleName") = Me.Mname.Text
Me.dsNewRow.Item("LastName") = Me.Lname.Text
Me.dsNewRow.Item("Birthday") = Me.dtpDateSelection.Value
Me.dsNewRow.Item("Gender") = Me.MaleRB.Text
Me.dsNewRow.Item("Gender") = Me.FemaleRB.Text
Me.dsNewRow.Item("Address") = Me.Address.Text
Me.ds.Tables("faculty").Rows.Add(Me.dsNewRow)
Me.da.Update(Me.ds, "faculty")
cn.Close()
MsgBox("Personnel Successfully Added")
Me.ListView2.Items.Clear()
Me.Personnelload()
End If
End Sub
答案 0 :(得分:0)
您要两次添加性别。
我真的认为这应该是一个radiobuttonlist,你应该使用所选的值。