我如何在没有Web服务的情况下直接从android更新我的ms sql服务器数据库(RESTFULapi)

时间:2018-09-06 18:02:38

标签: java android sql-server android-studio

我试图将数据直接插入到我的数据库中(在主机上)并通过sqlcommand轻松地将其标识(插入值..etc),当我尝试对更新语句执行相同操作时它不起作用..为什么??

btnpunchin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd _ HH:mm:ss");
            String currentDateandTime = sdf.format(new Date());


            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("UPDATE att" +
                          "SET name='yo' WHERE id= 404340 );");


                          st.executeUpdate("INSERT INTO att " +
                          "VALUES ('3'  , '"+ currentDateandTime+"' , '4002' , GETDATE() )");
                          con.close();

                }
            } catch (Exception e) {
                System.err.println("Got an exception! ");
                System.err.println(e.getMessage());
            }



        }
    });

0 个答案:

没有答案