mysql - ODBC update using ASP.NET forms -


how pass karthik@domain.com , kars@domain.com using asp.net forms (textbox) ?

string myconstring = "driver={mysql odbc 3.51 driver};" + "server=localhost;" + "database=new_db;" + "uid=root;" + "password=password;" + "option=3";  odbcconnection myconnection = new odbcconnection(myconstring);  odbccommand cmd = new odbccommand("update awm_create set referral_email='karthik@domain.com' email='kars@domain.com'" , myconnection);  myconnection.open();  cmd.executenonquery(); 

you have add 2 asp.net textbox controls web form , upon postback (using ispostback flag) can pull email address textboxes in pageload event... i.e. like:

private void page_load() {     if(page.ispostback)     {       // add validation here text boxes if need...       string refemail= txtreferralemail.text.trim();       string email = txtemail.text.trim();        //then can this:        var sql = string.format("update awm_create set referral_email='{0}' email='{1}'", refemail, email);        odbccommand cmd = new odbccommand(sql , myconnection);       try{            myconnection.open();            cmd.executenonquery();       }catch(exception e){            // log exception or whatever need       }     } } 

don't forget you'll need add 2 text boxes aspx form names txtreferralemail , txtemail.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -