Good afternoon
I am developing a custom made logistics application and in one of my forms i have 4 dropdown lists a textbox and gridview. The four dropdowns are populated with data from four different tables, while the textbox requires that data is inputed by the user.
My problem that i am finding is that when i go to save to the require table it is not saving any data.
The Dropdowns are a follows
Shipment No - display shipment number from table ShipmentNumbers
Client - lists all the clients
Brand - lists all the Brands
Currency - lists all the currenct currency's.
Season - textbox for user to enter relevant season eg. SU15
The below code is the Current Insert Statement using parameters.
Public Sub InsertShipmentNoDetails(ByVal RegShipmentID As Integer, ByVal ClientID As Integer, ByVal Season As String, ByVal BrandID As Integer, ByVal CurrencyID As Integer)
Dim myCommand As New SqlCommand()
myCommand.Connection = SQLCon
myCommand.CommandText = "INSERT INTO RegisterShipmentNoDetails(RegShipmentID, ClientID, Season, BrandID, CurrencyID)values(@RegShipmentID,@ClientID,@Season,@BrandID,@CurrencyID)"
myCommand.Parameters.AddWithValue("@RegShipmentID", RegShipmentID)
myCommand.Parameters.AddWithValue("@ClientID", ClientID)
myCommand.Parameters.AddWithValue("@Season", Season)
myCommand.Parameters.AddWithValue("@BrandID", BrandID)
myCommand.Parameters.AddWithValue("@Currency", CurrencyID)
myCommand.ExecuteNonQuery()
End Sub
The above method is then called from the save button as follows.
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
If ValidateData(txtSeason) = False Then
Exit Sub
End If
Try
mySQL.InsertShipmentNoDetails(txtSeason.Text, cboBrand.SelectedValue, cboClient.SelectedValue, cboCurrency.SelectedValue, cboShipmentNo.SelectedValue)
Catch ex As Exception
MessageBox.Show("Register Shipment Details Could Not Be Inserted," & ex.Message, ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
MessageBox.Show(" Register Shipments Details Successfully Inserted", ApplicationName, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
dvShipmentRegister.Table = mySQL.LoadShipmentNoDetails()
End Sub
Would appreciate if someone would explain what or where i am doing wrong in the above code.
Thanks.