public void insert(){ try{ Statement statement=connect.createStatement(); String myname=name.getText().toString(); ResultSet result=statement.executeQuery("select * from form1 where name='"+name.getText().toString()+"'"); String lname=result.toString(); if(myname==lname){ AlertDialog adb=new AlertDialog.Builder(this).create(); adb.setMessage("want to overwrite????"); adb.setButton("ok", new DialogInterface.OnClickListener( ) { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub try{ Statement statement1=connect.createStatement(); statement1.executeUpdate("insert into FORM1(NAME,CITY) " + "values('"+name.getText().toString() +"', '"+city.getText().toString()+"')"); statement1.close(); }catch(Exception e){ Log.e("ERROR", e.getMessage()); } } }); adb.setButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); adb.show(); } else{ Statement statement2=connect.createStatement(); statement2.executeUpdate("insert into FORM1(NAME,CITY) " + "values('"+name.getText().toString() +"', '"+city.getText().toString()+"')"); statement2.close(); } }catch(Exception e){ Log.e("ERROR", e.getMessage()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)