I\'m working in Visual Studio 2010 using linq-to-sql\'s DataContext
which has several maps to tables in the database. Now when I change something to the structu
let the connectionstrin be : string pp = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Data.mdf;Integrated Security=True;Connect Timeout=30";
and update task be the below mentioned :
public async Task callupdate()
{
try
{
int ppp = Convert.ToInt32(textBox1ID.Text);
DataClasses1DataContext dc = new DataClasses1DataContext(pp);
Person person = dc.Persons.Single(c => c.BusinessEntityID == ppp);
person.PersonType = Convert.ToString(PersonTypecomboBox1.SelectedItem);
person.PersonType = Convert.ToString(PersonTypecomboBox1.SelectedItem);
if (NameStylecomboBox1.SelectedText == "False")
person.NameStyle = false;
else
person.NameStyle = true;
person.Title = Convert.ToString(TitlecomboBox1.SelectedItem);
person.FirstName = FirstNametextBox2.Text;
person.MiddleName = MiddleNametextBox3.Text;
person.LastName = LastNametextBox4.Text;
person.Suffix = SuffixtextBox5.Text;
person.EmailPromotion = Convert.ToInt32(EmailPromotiontextBox6.Text);
person.ModifiedDate = DateTime.Today;
dc.SubmitChanges();
}
catch(Exception exp)
{
}
}
instead of DataClasses1DataContext dc = new DataClasses1DataContext();
DataClasses1DataContext dc = new DataClasses1DataContext(pp);
Vby calling SubmitChanges()
the update data that is the object of our class is actually being written in the actual database