数据未从android studio app插入ms sql数据库

时间:2018-01-24 10:56:48

标签: android-studio mssql-jdbc

我开发了一个与ms sql数据库连接的android应用程序,当我尝试插入数据时,它没有显示任何错误但是没有插入sql数据。请帮我。我使用androidstudio 3.0.1,Ms-sql R2数据库,jtds 1.3.1.jar用于jdbc连接。请帮我在数据库中插入数据。

protected String doInBackground(String... params)
       {
        String item = params[0];//username.getText().toString();
        String batch =params[1]; //password.getText().toString();
        String mtrs = params[2];
        String design = params[3];

        ConnectDb db = new ConnectDb();

            try
            {
                con = db.connectionclass();  // Connect to database
                if (con == null)
                {
                    z = "Check Your Internet Access!";
                }
                else
                {

                 String query = "insert into   [CE] values ('Null','Null','Null','item','batch','design','mtrs')";//"INSERT INTO [CE]VALUES"+"('"+barcode+"','"+rack+"','"+selves+"','"+item+"','"+batch+"','"+design+"','"+mtrs+"')";
                    Statement stmt = con.createStatement();

                    int rst = stmt.executeUpdate(query);

                   if(rst!=0)
                   {
                       z="Inserted rows"+rst;
                        isSuccess=true;
                        con.close();
                    }
                    else
                    {
                       z = "Invalid Credentials!";
                        isSuccess = false;
                    }
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;
                z = ex.getMessage();
            }

        return z;
    }}
    }

0 个答案:

没有答案