Good afternoon to all i am currently working on a logistics project, where in one of the forms the user needs to select a shipment number and other information related to the shipment. the form is made up of 4 dropdowns a textbox and a gridview as follows.

**The Dropdowns are a follows*
Shipment No - display the shipment number which was entered from a previous form and is saved in a database table named dbo.ShipmentNumbers
Client - lists all the clients names which are found in the dbo.Client table
Brand - lists all the Brand names which are found in the dbo.Brand table
Currency - lists all the currency's which are listed in the dbo.Currency table.
Season - textbox for user to enter relevant season eg. SU15

Apart from the above table i have a table named dbo.RegisterShipmentNoDetails, were the above dropdown tables are also connected through their repective Primary Keys.

The code that i have come up with till now is as follows for the Insert Statment

 Public Sub InsertShipmentNoDetails(ByVal RegShipmentID As Integer, ByVal ClientID As Integer, ByVal Season As String, ByVal BrandID As Integer, ByVal CurrencyID As Integer)
        'This inserts a new transit document to the database table in question
        'A set of parameters are passed then connected to the command object
        Dim myCommand As New SqlCommand()

        myCommand.Connection = SQLCon

        myCommand.CommandText = "INSERT INTO RegisterShipmentNoDetails(RegShipmentID, ClientID, Season, BrandID, CurrencyID)values(@RegShipmentID,@ClientID,@Season,@BrandID,@CurrencyID)"
        'Parameters are passed and connected to the Command Object

        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)

        'Here the command on the database is executed.

    End Sub

While the below code is done from the Save Button

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        'Validate if textbox is empty or not
        If ValidateData(txtSeason) = False Then

            Exit Sub
        End If

            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)
        'Gridview is loaded
        dvShipmentRegister.Table = mySQL.LoadShipmentNoDetails()

    End Sub

The following code is for the Select statment to be able to display in the datagrid area

Public Function LoadShipmentNoDetails() As Data.DataTable
        'In this function all the customers found in the database are loaded
        'Records are retrievd from the database into a datatable.

        Dim myCommand As New SqlCommand()
        myCommand.Connection = SQLCon
        myCommand.CommandText = "SELECT * FROM RegisterShipmentNoDetails"

        'The datatable is here created.
        Dim tblRegister As New Data.DataTable("Shipment Register Details")

        'The Datatable is returned
        Return tblRegister

    End Function

My problem is that when i am conimg to save the data from the form to the above table i am receiving an error that Register Shipment Details Could Not Be Inseted, Conversion from string 'FA15' to type integer is not valid.

Apart from the above i would like that in the datagrid the data that is displayed would be the one that was chosen by the user on the form and not the relevant number that the table would have given to the data. I know that my Select statement is just calling all the data from the required table.

I would appreciate it if someone could show me how i can do the above through an example or suggestions.

3 Years
Discussion Span
Last Post by Shark_1

Conversion from string 'FA15' to type integer is not valid

Please check the feild data types of that table which are not matching with your supplied data types.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.