i have this code
With ServiceInformationDialog
Dim cmd As New SqlCommand
Dim id As Integer
cn.Open()
cmd.Connection = cn
cmd.CommandText = " SELECT MAX(Service_ID) FROM Table_Service"
If IsDBNull(cmd.ExecuteScalar) Then
id = 1
.ServiceIDserviceTextBox1.Text = id
Else
id = cmd.ExecuteScalar + 1
.ServiceIDserviceTextBox1.Text = id
End If
cmd.Dispose()
End With
cn.Close()
it work but i want to make it as a function, so i can use it all over my project, and i want to know how to make it ?