2014-02-25 67 views
0

我得到以下異常:錯誤[HY090] [Informix .NET provider]無效的字符串或緩衝區長度。

"ERROR [HY090] [Informix .NET provider]Invalid string or buffer length." 

當我嘗試調用下面的方法:

public static int PrepareSal(int year, int month, int calcYear) 
     { 
      using (IfxConnection con = new IfxConnection(ConfigurationManager.ConnectionStrings["testable"].ToString())) 
      { 
       int res = 0; 
       StringBuilder cmdTxt = new StringBuilder(); 
       cmdTxt.Append("hkr_calc"); 
       using (var myIfxCmd = new IfxCommand(cmdTxt.ToString(), con)) 
       { 
        myIfxCmd.CommandType = CommandType.StoredProcedure; 

        if (con.State == ConnectionState.Closed) 
        { 
         con.Open(); 
        } 
        myIfxCmd.Parameters.Clear(); 
        myIfxCmd.Parameters.Add("p_year", IfxType.Integer, year); 
        myIfxCmd.Parameters.Add("p_month", IfxType.Integer, month); 
        myIfxCmd.Parameters.Add("p_calc_year", IfxType.Integer, calcYear); 
       // myIfxCmd.CommandTimeout = 15000; 
        res = myIfxCmd.ExecuteNonQuery(); //exception 
       } 
       con.Close(); 
       con.Dispose(); 
       return res; 
      } 
     } 

當我打電話我在SQL編輯器的程序,它工作正常,但它大約需要10分鐘!

回答

1

本來料想的是 cmdTxt.append(hkr_calc @p_year, @p_month, @p_calc_year)或其他一些。 ?無論如何,標記也許是參數的持有者。

PS你不需要關閉它,或者把它作爲它的使用塊放置,它總是會在開始時關閉,除非你填充了連接池。

相關問題