|
There is an ID field in the database, INT. Now every time a new record is added, the ID is automatically +1 from the segment. How to implement it? Here is my code:
Public Overrides Sub SaveForAdd2 ()
Dim drData As DataRow = DataSet11.Tables ("Application Form"). NewRow ()
Try
drData ("id") = TextBox36.Text
drData ("Application Workshop") = TextBox30.Text ()
drData ("Application Team") = TextBox31.Text ()
drData ("Applicant") = TextBox33.Text ()
drData ("Subject Leader") = TextBox34.Text ()
drData ("Application Date") = DateTimePicker1.Value.ToString ("yyyy-MM-dd")
drData ("name") = TextBox35.Text ()
drData ("Unit Price") = TextBox36.Text ()
drData ("Quantity") = TextBox37.Text ()
drData ("Total") = TextBox38.Text ()
drData ("Remarks") = TextBox39.Text ()
drData ("Use") = TextBox40.Text ()
Catch ex As Exception
MessageBox.Show ("The data format is incorrect!")
Exit Sub
End Try
Try
DataSet11.Tables ("Application Form"). Rows.Add (drData)
If Me.DataSet11.HasChanges = True Then
SqlDataAdapter1.Update (DataSet11)
End If
Catch ex As Exception
MessageBox.Show ("Data addition failed!")
End Try
End Sub |
|