Me.batch_number = 1 + Nz(DMax("batch_number", "tbl_batches", "customer_id = '" & Me.customer_id & "'"), 0) Me.create_date = Date Me.batch_reference = Me.customer_id & "-" & Me.batch_number Me.cd_reference = "CD" & Me.customer_id & "-" & Me.batch_number
Dim con As New SqlConnection Dim cmd As New SqlCommand Try con.ConnectionString = My.Settings.TestValue() con.Open() cmd.Connection = con txtBatchNumber = 1 + Nz(DMax("batch_number", "tbl_batches", "customer_id = '" & customer_id.text & "'"), 0) Dim customer_id, batch_number, batch_reference, create_date As String customer_id = txtCustomerNumber.Text batch_number = txtBatchNumber.Text batch_reference = txtBatchReference.Text create_date = Date.Today cmd.CommandText = "INSERT INTO tbl_batches([customer_id], [batch_number], [batch_reference], [create_date]) VALUES('" & customer_id & "', '" & batch_number & "', '" & batch_reference & "', '" & create_date & "')" cmd.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records") Finally con.Close() End Try End Sub
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Connect with Certified Experts to gain insight and support on specific technology challenges including: