I have tried many example that I have ran accross on the internet on how to add a row to a table in Visual Basic Express edition and of course none of them are working "Obviously I am Stupid". I have also created a new project and not have allowed the database to be copied into the project "getting past the whole making a copy of the database to the debug directory issue" I found the following articles at microsoft which tells you what I thought I needed to do:
1. http://msdn2.microsoft.com/en-US/library/5ycd1034(VS.80).aspx
2. http://msdn2.microsoft.com/en-US/library/ceab2k93(VS.80).aspx
3. http://msdn2.microsoft.com/en-US/library/xzb1zw3x(VS.80).aspx
So I tried all of them and none of them are working could someone please try and explain this to me if you could be so kind
Public
Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'StrangDataSet1.TestQuote1' table. You can move, or remove it, as needed. Me.TestQuote1TableAdapter.Fill(Me.StrangDataSet1.TestQuote1) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim newTestQuoteRow As DataRow = StrangDataSet1.Tables("TestQuote1").NewRow()newTestQuoteRow(
"Description") = "Web Press"newTestQuoteRow(
"Units") = 3newTestQuoteRow(
"Price") = 78.52newTestQuoteRow(
"Total") = 235.56StrangDataSet1.Tables(
"TestQuote1").Rows.Add(newTestQuoteRow)StrangDataSet1.TestQuote1.AcceptChanges()
Try Me.Validate() Me.TestQuote1BindingSource.EndEdit() Me.TestQuote1TableAdapter.Update(Me.StrangDataSet1.TestQuote1)MsgBox(
"Update successful") Catch ex As ExceptionMsgBox(
"Update failed") End Try 'Dim newTestQuoteRow As StrangDataSet1.TestQuote1Row 'newTestQuoteRow = StrangDataSet1.TestQuote1.NewTestQuote1Row() 'newTestQuoteRow.Description = "WebPress" 'newTestQuoteRow.Units = 3 'newTestQuoteRow.Price = 78.52 'newTestQuoteRow.Total = 235.56 'StrangDataSet1.TestQuote1.Rows.Add(newTestQuoteRow) 'StrangDataSet1.TestQuote1.AcceptChanges() 'Try ' Me.Validate() ' Me.TestQuote1BindingSource.EndEdit() ' Me.TestQuote1TableAdapter.Update(Me.StrangDataSet1.TestQuote1) ' MsgBox("Update successful") 'Catch ex As Exception ' MsgBox("Update failed") 'End TryEnd Sub

Very confused beginner what am I missing
jai_123
hey,
It seems the problem is at this line of code:
StrangDataSet1.TestQuote1.AcceptChanges()
You don't need it before you call the update method(). The reason is:
If you call the AcceptChanges before the update method, you'll lose the Rowstate for this newly added row, then when you call the update method in the savebutton_click function, the newly added row will be treated as an existing row, and won't be added to database. You can call AcceptChanges after submitting changes to a database (and it'll automatically get called by the update() method)
Hope it helps.
Aiwen Guo
VB Test Team
Ree84
Thank you Thank you Thank you!
I really appreciate your post I have been going crazy and this fixed my problem.