With Addition To
the process what is Told by S Mewara
that means
after marking the SaleDetailCode as An Identity Increament To One
You can use The max Function
to Increase the SaleDetailCode as Follows
and Call this function after you Click Your Save button
or Whenever you load the Form..
Public Sub Max_Id()
Dim sd As New SqlDataAdapter("Select max(SaleDetailCode) from SaleDetail", myCon.con())
Dim dt As New DataTable
sd.Fill(dt)
If (dt.Rows(0)(0).ToString() <> Nothing) Then
txtEid.Text = Convert.ToInt32(dt.Rows(0)(0).ToString()) + 1
Else
txtEid.Text = "1"
End If
End Sub
Also I will Suggest You to use a Textbox in
Place Of datagrid to Input the SaleDetailCode
and then hide The Textbox
here I have Provided the same Taking a TextBox named
txtEid and
myCon is the connection Class What i am using.
use the
Connection what you have Taken