Adding a new row to a database inserts a blank row between each new one.

The first time I press the Add Icon everything seems to work OK, but on each subsequent press of the Add Icon a correct new row and an unwanted blank row are added.

Any ideas what may cause this

Am I missing something from the code or is something incorrect in the code that would cause this  

 

Public Class Form1

  Dim drNew As DataRow

  Dim StrHour As Integer = 8

  Dim strMin As Integer = 0

  Dim Day As Integer = 1

  Dim Month As Integer = 1

  Dim Year As Integer = 2006

Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click

Dim newRow As DataRow = Me.TestdbDataSet.TeeTimes.NewRow()

drNew = Me.TestdbDataSet.TeeTimes.NewRow()

drNew.Item("DateTime") = Month.ToString + "/" + Day.ToString + "/" + Year.ToString

drNew.Item("Time") = StrHour.ToString & " : " & strMin.ToString

drNew.Item("Availability") = "4"

drNew.Item("Player1") = ""

drNew.Item("Player2") = ""

drNew.Item("Player3") = ""

drNew.Item("Player4") = ""

drNew.Item("Course") = "HPCC"

drNew.Item("Mode") = ""

drNew.Item("Points") = "0"

drNew.Item("Penalty") = "0"

Me.TestdbDataSet.TeeTimes.Rows.Add(drNew)

End Sub

End Class



Answer this question

Adding a new row to a database inserts a blank row between each new one.

  • ProgrammerMy

    Thanks again, Ken.

    Fast response.

    George

  • Ayenew Wudu

    In the bindingnavigators properties set the AddNew action to none. What is happening is everytime you click the add new button your code and the built in code is running. Setting the addnew action to none will prevent the built in code from running


  • user001

    hi,

    Is your problem solved If yes then could you please mark it as answered!

    Thank you,
    Bhanu.



  • Jeffery.Yin

    Thanks, for the answer to my problem. It worked like a charm. I changed the property to "none" and no more unwanted blank rows.

    Will this change affect me in other ways


    Thanks, again.

  • Jas98004

    No it wont


  • Adding a new row to a database inserts a blank row between each new one.