为什么我得到"转换失败" SQL Server 2012中的错误,即使我的参数类型是varchar?

时间:2015-08-10 20:03:01

标签: sql-server

几乎所有标题中都有说明。我有一个存储过程,其中包含一些我执行的输入参数并保存为对象。以下是输入参数的声明:

public static String ComputeHash(String[] dataArray, String privateKey) {

    String hash="";

    String data = "";

    for (String item : dataArray) {
        data += item;
    }

    try {

        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
        SecretKeySpec secret_key = new SecretKeySpec(privateKey.getBytes(), "HmacSHA256");
        sha256_HMAC.init(secret_key);

        //hash = Base64.encodeBase64String(sha256_HMAC.doFinal(data.getBytes()));
        //hash = Base64.encodeToString(sha256_HMAC.doFinal(data.getBytes("UTF-8")), Base64.DEFAULT);
        hash = new String(Base64.encodeBase64(sha256_HMAC.doFinal(data.getBytes("UTF-8"))));

    } catch (Exception e) {
        Toast.makeText(MyApplication.getAppContext(), "Error", Toast.LENGTH_LONG).show();
    }
    return hash;
}

public <S> S createService(Class<S> serviceClass){

    stamp = String.valueOf(System.currentTimeMillis() / 1000);//get the number of seconds since the epoch

    String[] data = new String[]{"thisisatestpublickey", 1438915015+"", "GET"};
    expectedSignature = ComputeHash(data, "thisistestprivatekey");

    RequestInterceptor requestInterceptor = new RequestInterceptor() {
        @Override
        public void intercept(RequestFacade request) {
            request.addHeader("Authorization", "Basic YXZlbmdlcnM6bWlnaHR5bWluZHM=");
            request.addHeader(ApplicationConstants.PublicKeyHeaderName, "thisisatestpublickey");
            request.addHeader(ApplicationConstants.StampHeaderName, 1438915015+"");
            request.addHeader(ApplicationConstants.SignatureHeaderName, expectedSignature);

        }
    };


}

但是,当我尝试执行这样的存储过程时:

@As_Document_NAME VARCHAR(50) = NULL,
@As_Company_NAME VARCHAR(50) = NULL, 
@As_Category_NAME VARCHAR(50) = NULL,
@As_Project_NAME VARCHAR(30) = NULL,
@As_Employee_Last_NAME VARCHAR(30) = NULL,
@As_Employee_First_NAME VARCHAR(30) = NULL,
@Ai_Employee_Ssn_NUMB INT = 0,
@As_Tag_TEXT VARCHAR(2000) = NULL,
@Ad_Start_DATE DATE = NULL,
@Ad_End_DATE DATE = NULL

我收到错误

  

转换varchar值时转换失败&#39; pls,I,cant&#39;数据类型int。

我该怎么做才能解决这个问题?我检查了执行语句和参数声明中的参数都是完全相同的顺序。

0 个答案:

没有答案