D
Dan Tallent
I have a form I'm playing around with that has some text boxes on it. I am
using SQL 2005 for my database.
I have a single table which I have created an object entity for. Customer
On the form I set the DataBindings Text value to "customerBindingSource -
CompanyName" on one of the textboxes.
The customerBindingSource was generated by the IDE and is pointing to the
Customer entity I created earlier. The CompanyName is a field within the
entity and underlying table.
During runtime I am using the follow code:
//----------------------------------------------------------------------------------
// This line is where my problem is.
this.CDC = new CustSiteDataContext(ConnString);
// Retreive customer record
var queryCust = from cust in CDC.Customers
where (cust.CustomerID == 100) && (cust.CompanyID == 5)
select cust;
this.customerBindingSource.DataSource = queryCust;
//----------------------------------------------------------------------------------
This works great, it reads the data in, I can make modifications and when I
click my button to save I execute:
this.CDC.SubmitChanges();
If the user wishes to abandon the changes, the idea is they can click a
button to do so. This code appears to work however I have to recreate a
new instance of the CustSiteDataContext for this to work.
In prior attempts I was looking at the refresh method, but I could not
figure out how to write it.
// CDC.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
Is the method I am using above the best/only way to implement "abandon"
changes ?
Thanks,
Dan
using SQL 2005 for my database.
I have a single table which I have created an object entity for. Customer
On the form I set the DataBindings Text value to "customerBindingSource -
CompanyName" on one of the textboxes.
The customerBindingSource was generated by the IDE and is pointing to the
Customer entity I created earlier. The CompanyName is a field within the
entity and underlying table.
During runtime I am using the follow code:
//----------------------------------------------------------------------------------
// This line is where my problem is.
this.CDC = new CustSiteDataContext(ConnString);
// Retreive customer record
var queryCust = from cust in CDC.Customers
where (cust.CustomerID == 100) && (cust.CompanyID == 5)
select cust;
this.customerBindingSource.DataSource = queryCust;
//----------------------------------------------------------------------------------
This works great, it reads the data in, I can make modifications and when I
click my button to save I execute:
this.CDC.SubmitChanges();
If the user wishes to abandon the changes, the idea is they can click a
button to do so. This code appears to work however I have to recreate a
new instance of the CustSiteDataContext for this to work.
In prior attempts I was looking at the refresh method, but I could not
figure out how to write it.
// CDC.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
Is the method I am using above the best/only way to implement "abandon"
changes ?
Thanks,
Dan