|
-
May 3rd, 2008, 02:04 AM
#1
Thread Starter
New Member
[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
-
May 3rd, 2008, 04:17 AM
#2
Re: [2008] Dataset and tableAdapter does not update databas
-
May 3rd, 2008, 04:59 AM
#3
Thread Starter
New Member
Re: [2008] Dataset and tableAdapter does not update databas
 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>
-
May 3rd, 2008, 11:30 AM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|