Results 1 to 6 of 6

Thread: [RESOLVED] [2005] DataSource Update problem

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved [RESOLVED] [2005] DataSource Update problem

    Code:
                Dim row As DataRowView
                row = DirectCast(Me.Lista_utilizatoriBindingSource.AddNew, DataRowView)
    
                Me.dgv_utilizatori.CurrentRow.Cells(0).Value = Me.txt_nume_utilizator.Text
    ...            
    ...
                Me.dgv_utilizatori.CurrentRow.Cells(16).Value = Me.txt_ultima_autentificare.Text
                Me.dgv_utilizatori.CurrentRow.Cells(17).Value = Me.txt_data_inregistrare.Text
    
                Me.Lista_utilizatoriBindingSource.EndEdit()
                Me.Lista_utilizatoriTableAdapter.Update(Me.Utilizatori_DataSet.lista_utilizatori)
    This code is not working to insert a new record (row) to the database.
    It's modifying me the current row selected.

    What's wrong ?
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    Banned
    Join Date
    Jan 2008
    Posts
    79

    Re: [2005] DataSource Update problem

    nushtiu, imi pare rau

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] DataSource Update problem

    It shouldn't be a surprise that you're editing the current row when you're specifically referring to the CurrentRow property. If you want to set the field values of the row you just added then do just that. You've got a reference to it right there:
    Code:
    row = DirectCast(Me.Lista_utilizatoriBindingSource.AddNew, DataRowView)
    Last edited by jmcilhinney; Jan 3rd, 2008 at 07:20 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2005] DataSource Update problem

    Quote Originally Posted by jmcilhinney
    It shouldn't be a surprise that you're editing the current row when you're specifically referring to the CurrentRow property. If you want to set the field values of the row you just added then do just that. You've got a reference to it right there:
    Code:
    row = DirectCast(Me.Lista_utilizatoriBindingSource.AddNew, DataRowView)
    I have a DGV and some TextBoxe's bounded to a binding source.

    I've try it the .Insert() command but is not working too...

    Then ?

    Code:
    if myproblem = "no_results" then 
    
    post on vbforums.com
    
    else
    
    google
    
    end if
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] DataSource Update problem

    If your TextBoxes are bound to the same BindingSource as the grid then you don't need to do anything. Creating a new row and entering data in the TextBoxes will automatically push the data to the BindingSource. The grid is bound to the same BindingSource so it already contains the new data.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [2005] DataSource Update problem

    Quote Originally Posted by jmcilhinney
    If your TextBoxes are bound to the same BindingSource as the grid then you don't need to do anything. Creating a new row and entering data in the TextBoxes will automatically push the data to the BindingSource. The grid is bound to the same BindingSource so it already contains the new data.
    Do you know what jmcilhinney ?

    Works now...

    I know that you are bored to see all the time this on the forum but... there are poples like me that want to know more sily things. It's a matter of time, someday i will be able to tell to other users what did you tell me now... (is a long way, but i will).

    Thanks alot man for your big help, realy thanks!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width