Click here to Skip to main content
15,918,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am software developper, now i am trying to update data from mysql database using entity data model as connection, but there is no issue and after compulation there is no error shown.

There is my code.

protected void AlterCustomerButton_Click(object sender, EventArgs e)
{

int IdClient= Convert.ToInt32(Request.QueryString["ClientID"]);
var query = from cl in context.clients orderby cl.NomProprietaire select cl;

foreach(var detail in query){

if(detail.ClientID==IdClient){

detail.NumeroIdentificationFiscal = NumIdent.Text;
detail.NomProprietaire = Nom.Text;
detail.Province = DropDownList5.SelectedValue;
detail.NumCNI = cni.Text;
detail.CategorieProprietaire = DropDownList1.SelectedValue;

//Vider les zones de saisies
NumIdent.Text="";
Nom.Text="";
DropDownList5.Text="";
cni.Text="";
DropDownList1.Text="";

}
}
//Appliquer les modifications sur le client dont l'identifiant==IdClient
context.SaveChanges();
string script = "<script language='JavaScript'> alert('Client mofifie avec succes');</script>";

ClientScript.RegisterClientScriptBlock(this.GetType(), "script", script);
Response.Redirect("~/Forms/WebForm1.aspx");


}
Please all help is welcome.
Posted

1 solution

C#
int IdClient= Convert.ToInt32(Request.QueryString["ClientID"]);
var query = (from cl in context.clients 
            Where cl.ClientID==IdClient select cl).SingleOrDefault();
 
if(query!=null){
 
query.NumeroIdentificationFiscal = NumIdent.Text;
query.NomProprietaire = Nom.Text;
query.Province = DropDownList5.SelectedValue;
query.NumCNI = cni.Text;
query.CategorieProprietaire = DropDownList1.SelectedValue;
context.SaveChanges();
 
//Vider les zones de saisies
NumIdent.Text="";
Nom.Text="";
DropDownList5.Text="";
cni.Text="";
DropDownList1.Text="";
 
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900