Hi Everyone:
This problem has been plaguing me for three days, and I canâ??t for the life
of me find a logical reason why this problem occurs.
My problem occurs when I try to write data into a dataset that contains
nothing more than the table schema.
This subroutine is supposed to write a new record into the dataset.
Private Sub New_Bindings(ByVal intOrdinal As Integer, _
ByVal strCode As String, _
ByVal strName As String)
tblBindings = MyDataSet.Tables("tblBindings")
drCurrent = tblBindings.NewRow()
drCurrent("Ordinal") = intOrdinal
drCurrent("BindingCode") = strCode
drCurrent("BindingName") = strName
tblBindings.Rows.Add(drCurrent)
'Call Clear_Form()
End Sub
I write new data into the dataset when this subroutine is activated. It is
activated when the Private Sub BindingNavigatorAddNewItem_Click event is
triggered. The AddNew Button on the BindingNavigator control on the form.
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles
BindingNavigatorAddNewItem.Click
Call New_Bindings(1, "SDLS", "Saddle-stitch")
Call New_Bindings(2, "SPRL", "Spiral Bound")
Call New_Bindings(3, "STUL", "Staple Upper Left")
Call New_Bindings(4, "STUR", "Staple Upper Right")
Call New_Bindings(5, "ST2L", "Two Staples on left side")
End Sub
The datasetâ??s data should read like this:
BindingID â?? 1
Ordinal â?? 1
Code â?? SDLS
Name â?? Saddle-stitch
BindingID â?? 2
Ordinal â?? 2
Code â?? SPRL
Name â?? Spiral Bound
BindingID â?? 3
Ordinal â?? 3
Code â?? STUL
Name â?? Staple Upper Left
BindingID â?? 4
Ordinal â?? 4
Code â?? STUP
Name â?? Staple Upper Right
BindingID â?? 5
Ordinal â?? 5
Code â?? ST2l
Name â?? Two Staples on Left Side
What I am actually getting is:
BindingID â?? 0
Ordinal â?? 1
Code â?? SDLS
Name â?? Saddle-stitch
BindingID â?? 1
Ordinal â?? 2
Code â?? SPRL
Name â?? Spiral Bound
BindingID â?? 2
Ordinal â?? 3
Code â?? STUL
Name â?? Staple Upper Left
BindingID â?? 3
Ordinal â?? 4
Code â?? STUP
Name â?? Staple Upper Right
BindingID â?? 4
Ordinal â?? 5
Code â?? ST2l
Name â?? Two Staples on Left Side
For some reason when the first record is written out to the dataset the auto
increment field (BindingID) is not incremented to one when the record is
written. It has an ID of â??0â?? which logically canâ??t happen when the column has
been defined to be an auto increment starting at one and incrementing by one
every time a new record is added.
Can anyone tell me why this is happening and what I need to do to correct it?
Thanks,
--
Mark