Click here to Skip to main content
15,887,175 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionvalidation control final? Pin
classy_dog29-Oct-11 8:05
classy_dog29-Oct-11 8:05 
AnswerRe: validation control final? Pin
Brij1-Nov-11 1:34
mentorBrij1-Nov-11 1:34 
QuestionHow to implement an automatic task in asp.net Pin
TRAORE cheickna29-Oct-11 2:40
TRAORE cheickna29-Oct-11 2:40 
AnswerRe: How to implement an automatic task in asp.net Pin
Philippe Mori29-Oct-11 3:15
Philippe Mori29-Oct-11 3:15 
GeneralRe: How to implement an automatic task in asp.net Pin
TRAORE cheickna29-Oct-11 3:41
TRAORE cheickna29-Oct-11 3:41 
GeneralRe: How to implement an automatic task in asp.net Pin
Philippe Mori29-Oct-11 4:23
Philippe Mori29-Oct-11 4:23 
AnswerRe: How to implement an automatic task in asp.net Pin
Not Active29-Oct-11 4:23
mentorNot Active29-Oct-11 4:23 
Questionwebform error Pin
sc steinhayse28-Oct-11 11:42
sc steinhayse28-Oct-11 11:42 
I am working on a C# asp.net 2010 web form web page I just wrote. Right now I am getting the error

'Cannot add an entity that already exists'. I get that error on the following line of code: attPlanDataContext.SubmitChanges();

I am trying to write to a table that has one to many rows that relate to the main table. When I try to add the second row to the table, that is when the error occurs.

I am hoping you can suggest what I need to change to fix this error. The following is the code that is affected by this error:

[^]protected void submitbutton(object sender, EventArgs e)
{

if (!Page.IsPostBack)
return;

CustomerDataContext attDataContext = new CustomerDataContext();
Customer att = null;
att = new Customer();
InsertCustomer(att);
attDataContext.Customer.InsertOnSubmit(att);
attDataContext.SubmitChanges();
CustomerDataContext attPlanDataContext = new CustomerDataContext();
Plan attplan = null;
attplan = new Plan();
InsertPlans(attplan, att, attPlanDataContext);

}
protected void InsertCustomer(Customer att)
{
// fills in data here
}
protected void InsertPlans(Plan attplan,Customer att, CustomerDataContext attPlanDataContext)
{


for (int i = 0; i < ChkBoxLstPlan.Items.Count; i++)
{

if (ChkBoxLstPlan.Items[i].Selected)
{
attplan.Att_id = att.Att_id;
attplan.Number = ChkBoxLstPlan.Items[i].Value.Substring(0, 5);
// Update the database
attPlanDataContext.Plans.InsertOnSubmit(attplan);
attPlanDataContext.SubmitChanges();
}
}

}
[^]
Questioncustom validator Pin
Member 821751728-Oct-11 5:14
Member 821751728-Oct-11 5:14 
AnswerRe: custom validator Pin
Brij1-Nov-11 1:45
mentorBrij1-Nov-11 1:45 
QuestionThe connection was closed unexpectedly Pin
oujeboland28-Oct-11 2:08
oujeboland28-Oct-11 2:08 
AnswerRe: The connection was closed unexpectedly Pin
Dennis E White28-Oct-11 6:14
professionalDennis E White28-Oct-11 6:14 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland28-Oct-11 7:15
oujeboland28-Oct-11 7:15 
GeneralRe: The connection was closed unexpectedly Pin
Dennis E White28-Oct-11 7:30
professionalDennis E White28-Oct-11 7:30 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland28-Oct-11 21:46
oujeboland28-Oct-11 21:46 
GeneralRe: The connection was closed unexpectedly Pin
Dennis E White29-Oct-11 5:16
professionalDennis E White29-Oct-11 5:16 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland29-Oct-11 20:22
oujeboland29-Oct-11 20:22 
AnswerRe: The connection was closed unexpectedly Pin
jkirkerx28-Oct-11 18:40
professionaljkirkerx28-Oct-11 18:40 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland28-Oct-11 22:12
oujeboland28-Oct-11 22:12 
GeneralRe: The connection was closed unexpectedly Pin
jkirkerx29-Oct-11 7:20
professionaljkirkerx29-Oct-11 7:20 
GeneralRe: The connection was closed unexpectedly Pin
oujeboland29-Oct-11 20:26
oujeboland29-Oct-11 20:26 
QuestionLogin Management Pin
shashiankam27-Oct-11 20:14
shashiankam27-Oct-11 20:14 
AnswerRe: Login Management Pin
Richard MacCutchan27-Oct-11 21:50
mveRichard MacCutchan27-Oct-11 21:50 
GeneralRe: Login Management Pin
shashiankam29-Oct-11 1:19
shashiankam29-Oct-11 1:19 
AnswerRe: Login Management Pin
jkirkerx28-Oct-11 18:48
professionaljkirkerx28-Oct-11 18:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.