c# - How can i access previous value of a variable? -
i want access previous value of global variable "i". here code.
int = 0; private void btnsave_click(object sender, eventargs e) { if (con.state == connectionstate.open) { con.close(); } try { con.open(); i++; //int i2=i-1; string s = "insert add_information values('"+i +"','"+ txtcompanyname.text + "','" + txtoffaddress1.text + "','" + txtoffaddress2.text + "','" + txtcityandpin.text + "','" + txtcontactpersonname.text + "','" + txtdesignation.text + "'," + txtoffphoneno.text + "," + txtfaxno.text + "," + txtmobileno.text + ",'" + txtofficialemailid.text + "','" + txtpersonalemailid.text + "','" + txtalternativecontactpersonname.text + "','" + txtwebsite.text + "','" + txtclientclassification.text + "','" + txtdetails.text + "','" + txtgroup.text + "','" + picturebox1.image + "')"; sqlcommand cmd = new sqlcommand(s, con); if (cmd.executenonquery() >= 1) { messagebox.show("succesfully updated !!"); } con.close(); } catch (exception ex) { /*if(txtfaxno.text==""||txtmobileno.text==""||txtoffphoneno.text=="") { messagebox.show("fax no,mobile no,office no should not character"); }*/ con.close(); messagebox.show(ex.message); } i want access previous value of stored in data table add_information after current form closed
i agree adil if don't want make
add_information
identity write stored procedure return max value of
add_infomation
from table , use it
Comments
Post a Comment