I'm new to vb.net (having moved from VBA) and I'm in the process of converting a simple database into vb.net using Visual Studio 2013. I have quickly realised that stored procedures are going to be the way forward regarding updating my SQL database and for performing queries on such data.
Currently when I create a new batch associated with a customer in the database I check the tbl_batches table to see if that customer has already had a batch created and if they do I look for the most recent batch created and add 1 to that number and return that to the user. If there are no batches in the the system for the customer then the batch numbering starts at 01.
The VBA code I had for this action was:
1 + Nz(DMax("batch_number", "tbl_batches", "customer_id = '" & Me.customer_id & "'"), 0)
For the life of me I have no idea how this would convert into a stored procedure. So that my form field gets filled with either a 01 if there is not batch for the client in the database or returns the most recent addition and adds 1 to this number (advancing the batch number by 1)