1,105,328 Community Members

Unable to insert row

Member Avatar
bluehangook629
Posting Whiz in Training
207 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
 
0
 

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
Member Avatar
adam_k
Veteran Poster
1,056 posts since Jun 2011
Reputation Points: 239 [?]
Q&As Helped to Solve: 212 [?]
Skill Endorsements: 17 [?]
 
0
 

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

Member Avatar
bluehangook629
Posting Whiz in Training
207 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
adam_k
Veteran Poster
1,056 posts since Jun 2011
Reputation Points: 239 [?]
Q&As Helped to Solve: 212 [?]
Skill Endorsements: 17 [?]
 
0
 

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

Member Avatar
bluehangook629
Posting Whiz in Training
207 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
 
0
 

I see what I missed.
Thanks for the help

Question Answered as of 2 Years Ago by adam_k
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: