[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:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Validate()
Me.CategoryCompanyBindingSource.EndEdit()
Me.CategoryCompanyTableAdapter.Insert(CategoryCompanyNameTextEdit.Text)
Me.CategoryCompanyTableAdapter.Fill(Me.DatabasecrmDataSet.CategoryCompany)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Validate()
Me.CategoryCompanyBindingSource.EndEdit()
Me.CategoryCompanyTableAdapter.Update(CategoryCompanyNameTextEdit.Text, ListBox1.SelectedValue)
Me.CategoryCompanyTableAdapter.Fill(Me.DatabasecrmDataSet.CategoryCompany)
End Sub
TNX :)
Re: [2008] Dataset and tableAdapter does not update databas
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:
<connectionStrings>
<add name="alex.My.MySettings.DatabasecrmConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Databasecrm.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
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.