Hey guys,
As you can see below I am trying to add row of data to a table called tblOut.
When i execute the code, it works without a single error message but the problem is I dont see any new record when i preview my table data.
Can anyone tell me what I did wrong
Thanks

Private Sub btnPrepare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrepare.Click

        Dim shipCls As New WarehouseClassLibrary.ShippingClass
        'Declare newOutRow as controller for tblOutRow
        Dim newOutRow As GCR_ICDataSet1.tblOutRow
        newOutRow = GCR_ICDataSet1.tblOut.NewtblOutRow()


        'Creates an instance of user message box confirming user of completion
        Dim result As MsgBoxResult = MessageBox.Show("Are you ready to add items to this order?", "Add Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)

        'Creates an instance of input error trap were the fields are checked to see if any null
        If result = MsgBoxResult.Yes Then
            If txtSalesOrder.Text = Nothing Or txtCarrier.Text = Nothing Or txtTracking.Text = Nothing Then
                MessageBox.Show("Please complete required fields", "Incomplete Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            Else
                'Obtain new Control number
                txtOutID.Text = shipCls.Get_ControlID()

                'Create an instance of adding new items to the rows.
                newOutRow.OutID = txtOutID.Text
                newOutRow.OrderID = txtSalesOrder.Text
                newOutRow.Carrier = txtCarrier.Text
                newOutRow.Tracking = txtTracking.Text
                newOutRow.ShipDate = Today()
                GCR_ICDataSet1.tblOut.Rows.Add(newOutRow)

                'Upon completion, Shipment info group box is disabled and add item group box is enabled.
                gbShipInfo.Enabled = False
                btnAdd.Enabled = True
                gbItem.Enabled = True
                txtModel.Focus()
            End If
        End If



    End Sub

Recommended Answers

All 4 Replies

What is GCR_ICDataSet1 and how is this connected to your table?

GCR_ICDataSet1 is a data source containing all of the tables, views, procedures that are part of my SQL database. I am fairly new to database so I dont know what you mean by how is it connected to the table.

I'm guessing that the GCR_ICDataSet1 is a dataset (as the name suggests), which get's data from an SQLDataAdapter.
What you've done so far is add a record in the "copy" of your actual table which is stored in your dataset (which get's copied when you fill the dataset).
You can actually read/edit/delete the data you've just inserted but only from the dataset.
After you've created the row in the dataset version of the table you need to transfer the changes to your actual table. In order to do so you need to prepare your DataAdapter and ask it to update your table.
You can read all about it here: http://support.microsoft.com/kb/301248

I see what I missed.
Thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.