Results 1 to 4 of 4

Thread: [2008] Dataset and tableAdapter does not update databas

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    6

    [2008] Dataset and tableAdapter does not update databas

    HELO

    in order to insert and Update i am using tableAdapte and Dataset, in first look it seems to be working, i do see the insert data in one of my bound controls (listbox) however when i close the app and run it again I DO NOT SEE ANY NEW DATA IN THE TABLE.
    i read http://msdn2.microsoft.com/en-us/lib...89(VS.80).aspx
    and set the db and dataset Copy to Output Directory to Copy if newer but it still not working.

    this is my code:

    INSERT AND UPDATE Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Me.Validate()
    3.         Me.CategoryCompanyBindingSource.EndEdit()
    4.         Me.CategoryCompanyTableAdapter.Insert(CategoryCompanyNameTextEdit.Text)
    5.         Me.CategoryCompanyTableAdapter.Fill(Me.DatabasecrmDataSet.CategoryCompany)
    6.     End Sub
    7.  
    8.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    9.         Me.Validate()
    10.         Me.CategoryCompanyBindingSource.EndEdit()
    11.         Me.CategoryCompanyTableAdapter.Update(CategoryCompanyNameTextEdit.Text, ListBox1.SelectedValue)
    12.         Me.CategoryCompanyTableAdapter.Fill(Me.DatabasecrmDataSet.CategoryCompany)
    13.     End Sub


    TNX

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2008] Dataset and tableAdapter does not update databas


  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    6

    Re: [2008] Dataset and tableAdapter does not update databas

    Quote Originally Posted by mendhak
    i saw this post, but as i write, i set the Copy to Output Directory to Copy if newer.
    however i didn't understand the "|DataDirectory|" in connection string

    is there any problem with my connection string?

    connection string Code:
    1. <connectionStrings>
    2.         <add name="alex.My.MySettings.DatabasecrmConnectionString"
    3.             connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Databasecrm.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
    4.             providerName="System.Data.SqlClient" />
    5.     </connectionStrings>

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

    Re: [2008] Dataset and tableAdapter does not update databas

    Why are you inserting and updating one record at a time anyway? Just Fill the DataTable, bind it, add or edit all your data, then Update it all in one go. You'd only use those DB Direct methods if your data is coming from controls or some other source not bound to a DataTable. Yours obviously is because you've got a BindingSource.
    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

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