04-11-23, 01:42 PM
هذا الكود كاملا اخي
Dim cs As New SqlConnection("Data Source=.\SQLEXPRESS; INITIAL CATALOG=AutoID; INTEGRATED SECURITY=true;")
Dim ds As New DataSet
Dim da As New SqlDataAdapter("SELECT TOP 1 ID FROM tblAutoID WHERE MyYear=" & DateTimePicker1.Value.Year & " ORDER BY ID DESC", cs)
da.Fill(ds, "tblAutoID")
Dim dv As New DataView(ds.Tables("tblAutoID"))
If Me.BindingContext(dv).Count > 0 Then
txtID.Text = CInt(Me.BindingContext(dv).Current("ID")) + 1
Else
txtID.Text = 1
End If
Dim cs As New SqlConnection("Data Source=.\SQLEXPRESS; INITIAL CATALOG=AutoID; INTEGRATED SECURITY=true;")
Dim ds As New DataSet
Dim da As New SqlDataAdapter("SELECT TOP 1 ID FROM tblAutoID WHERE MyYear=" & DateTimePicker1.Value.Year & " ORDER BY ID DESC", cs)
da.Fill(ds, "tblAutoID")
Dim dv As New DataView(ds.Tables("tblAutoID"))
If Me.BindingContext(dv).Count > 0 Then
txtID.Text = CInt(Me.BindingContext(dv).Current("ID")) + 1
Else
txtID.Text = 1
End If
