Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
im working in a simple attendance app with android studio and sql server db (in hosting site ) after the user login he have to click punch-in when he do that i want to get the name of the current user and date and time to be posted in the db ,, although ididnt create a restfulapi it works fine to me

some of the code

What I have tried:

Java
public class attendance extends AppCompatActivity {

    ConnectionClass connectionClass;
    Button btnpunchout , btnpunchin;
    String z = "" ;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_attendance);

        connectionClass = new ConnectionClass();
        btnpunchin = (Button) findViewById(R.id.btnpunchin);
        btnpunchout = (Button) findViewById(R.id.btnpunchout);


        btnpunchin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                try {

                    Connection con = connectionClass.CONN();
                    if (con == null) {
                        z = "there is something wrong ";
                    } else{
                        Toast.makeText(attendance.this, "Punch-in successful!!!" ,Toast.LENGTH_SHORT).show();
                    Statement st = con.createStatement();
                     st.executeUpdate("INSERT INTO emp_attendance " +
                                "VALUES (8080, 'fatma', 'it444')");
                    con.close();
                }
                } catch (Exception e) {
                    System.err.println("Got an exception! ");
                    System.err.println(e.getMessage());
                }



            }
        });





    }



    }
Posted
Comments
David Crow 4-Sep-18 10:20am    
"...it works fine to me"

So then what's the problem?

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