Writing to Datatable
Writing to Datatable
Writing to Datatable
Writing to Datatable
Writing to Datatable
Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable
Writing to Datatable Writing to Datatable
Writing to Datatable
Go Back  Xtreme Visual Basic Talk > > > Writing to Datatable


Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2013, 12:15 PM
Chinner Chinner is offline
Newcomer
 
Join Date: Jun 2013
Posts: 1
Default Writing to Datatable


I cant seem to make my program write to my dataset. Any input is appreciated.

Add Button Code:

Code:
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
Properties:

Code:
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


Dialogue OK Button:

Code:
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
On my my main form I have an 'Add Button". When it is clicked, it opens a dialogue that accepts the input for a new datarow and returns the properties to the main form. Problem is, it doesn't write the new row to the dataset.

ps. Yes I named the dataset "Dataset1", and yes I know I shouldn't.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Writing to Datatable
Writing to Datatable
Writing to Datatable Writing to Datatable
Writing to Datatable
Writing to Datatable
Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable Writing to Datatable
Writing to Datatable
Writing to Datatable
 
Writing to Datatable
Writing to Datatable
 
-->