0
내 프로그램을 내 데이터 세트에 쓰는 것 같습니다. 모든 입력을 부탁드립니다.데이터 세트에 쓰기 문제
추가 버튼 코드 :
Private Sub AddPlayerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddPlayerToolStripMenuItem.Click
Using dialogue As New newMatchForm
If dialogue.ShowDialog = DialogResult.OK Then
Dim prating As Integer
Dim givendate As String = newMatchForm.givenDate
Dim p1 As String = newMatchForm.givenP1
Dim p2 As String = newMatchForm.givenP2
Dim winner As String = newMatchForm.givenWinner
prating = prating + newMatchForm.prating
Dim newrow As PvPLeaderboard.DataSet1.MatchesRow = CType(DataSet1.Matches.NewRow, PvPLeaderboard.DataSet1.MatchesRow)
newrow._Date = givendate
newrow.Player_1 = p1
newrow.Player_2 = p2
newrow.Winner = winner
DataSet1.Matches.Rows.Add(newrow)
Me.MatchesTableAdapter.Update(Me.DataSet1.Matches)
End If
End Using
End Sub
속성 :
Public ReadOnly Property givenDate() As String
Get
Return Me.DateTimePicker1.Text
End Get
End Property
Public ReadOnly Property givenP1() As String
Get
Return Me.player1Combobox.SelectedItem.ToString
End Get
End Property
Public ReadOnly Property givenP2() As String
Get
Return Me.player2Combobox.SelectedItem.ToString
End Get
End Property
Public ReadOnly Property givenWinner() As String
Get
If player1RadioButton.Checked = True Then
Return Me.player1Combobox.SelectedItem.ToString
Else
Return Me.player2Combobox.SelectedItem.ToString
End If
End Get
End Property
Public ReadOnly Property prating() As Integer
Get
If player1RadioButton.Checked = True Then
Return CInt(Me.p1RatingLabel.Text.)
Else
Return CInt(Me.p2RatingLabel.Text)
End If
End Get
End Property
대화 OK 버튼 :. 내 내 주요 양식에
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
If player1Combobox.SelectedIndex = player2Combobox.SelectedIndex Then
MessageBox.Show("Cannot match the same players, please select a valid match-up.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf player1RadioButton.Checked = False AndAlso player2RadioButton.Checked = False Then
MessageBox.Show("Please select a winner", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Me.DialogResult = DialogResult.OK
Me.Close()
End If
End Sub
나는 때를에 '버튼을 추가 "가 클릭하면 새 데이터 로우에 대한 입력을 받아들이는 대화 상자가 열리고 기본 폼에 속성이 반환됩니다. 데이터 세트에 새 행을 쓰지 마십시오.
ps. 예, 데이터 집합 이름을 "Dataset1"로 지정했는데, 그렇지 않아야합니다.
디버그하셨습니까? Me.MatchesTableAdapter.Update (Me.DataSet1.Matches)가 호출됩니까? – Paparazzi
AddPlayerToolStripMenuItem_Click에서 왜 입력 양식의 클래스이고 "대화"가 아닌 "newMatchForm"의 값을 얻을 수 있습니까? 어쩌면 내가 틀렸어? –