1

挿入すると次の例外が発生します:

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

いつ

obj.Request_file = null;//of byte[] type

          using (IfxConnection con = new IfxConnection(ConfigurationSettings.AppSettings["con1"].ToString()))
            {
                con.Open();
                StringBuilder cmdTxt = new StringBuilder();

                cmdTxt.Append(" INSERT INTO request_data(req_ser, req_year, req_date, req_emp_type, req_emp_num, req_emp_name, person_type,person_num,person_name,about_person,other_description,main_code , year,req_desc, login_num , req_title,request_file) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?) ");

                int MaxFollowSerial = Get_Max_FollowSerial(int.Parse(obj.RequestYear.ToString())) + 1;
                IfxCommand myIfxCmd = new IfxCommand(cmdTxt.ToString(), con);

                myIfxCmd.CommandType = CommandType.Text;
                myIfxCmd.Parameters.Clear();

                myIfxCmd.Parameters.Add("req_ser", MaxFollowSerial.ToString());
                myIfxCmd.Parameters.Add("req_year", obj.RequestYear.ToString());
                myIfxCmd.Parameters.Add("req_date", obj.RequestDate.ToString().Split(' ')[0]);
                myIfxCmd.Parameters.Add("req_emp_type", obj.RequestEmpType.ToString().Trim());
                myIfxCmd.Parameters.Add("req_emp_num", obj.RequestEmpNum.ToString().Trim());
                myIfxCmd.Parameters.Add("req_emp_name", obj.RequestEmpName.ToString().Trim());
                myIfxCmd.Parameters.Add("person_type", obj.PersonType.ToString().Trim());
                myIfxCmd.Parameters.Add("person_num", obj.PersonNum.ToString().Trim());
                myIfxCmd.Parameters.Add("person_name", obj.PersonName.ToString().Trim());
                myIfxCmd.Parameters.Add("about_person", obj.AboutPerson.ToString().Trim());
                myIfxCmd.Parameters.Add("other_description", obj.OtherDescription.ToString().Trim());
                myIfxCmd.Parameters.Add("main_code", obj.MainCode.ToString());
                myIfxCmd.Parameters.Add("year", obj.Year.ToString());
                myIfxCmd.Parameters.Add("req_desc", obj.RequestDescription.ToString().Trim());
                myIfxCmd.Parameters.Add("login_num", obj.LoginNum.ToString());
                myIfxCmd.Parameters.Add("req_title", obj.Title.ToString());
                myIfxCmd.Parameters.Add("request_file", obj.Request_file);
                int affectedRow = myIfxCmd.ExecuteNonQuery();
                con.Close();
                con.Dispose();
                if (affectedRow > 0)
                    return MaxFollowSerial;
                else
                    return affectedRow;
            }
4

1 に答える 1

3

これを試して:

if(obj.Request_file != null)
    myIfxCmd.Parameters.Add("request_file", obj.Request_file);
else
    myIfxCmd.Parameters.Add("request_file", DBNull.Value);
于 2013-02-13T14:05:30.830 に答える