0

こんにちは、以下のコードを使用し、XML パラメータを C# から SQL Server に渡しました。以下のエラーが表示されます。

<?xml version="1.0"?>
<ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <int>1</int>
 </ArrayOfInt>

ここに私のC#コードがあります:

 private void searchLeval1Language()
{

    List<int> ClientId = new List<int>();
    List<int> FieldId = new List<int>();
    List<int> StatusId = new List<int>();
    string[] Client = null;
    Client = hdnClientID.Value.Split(',');
    if (Client != null)
    {

        foreach (string s in Client)
        {
            if (!string.IsNullOrEmpty(s))
            {
                ClientId.Add(Convert.ToInt32(s));
            }
        }
    }
    string[] Field = null;
    Field = hdnFieldID.Value.Split(',');
    if (Field != null)
    {
        foreach (string s in Field)
        {
            if (!string.IsNullOrEmpty(s))
            {
                FieldId.Add(Convert.ToInt32(s));
            }
        }
    }
    XmlSerializer xs = new XmlSerializer(typeof(List<int>));
    MemoryStream ms = new MemoryStream();
    xs.Serialize(ms, ClientId);
    string xmlClientid = UTF8Encoding.UTF8.GetString(ms.ToArray());
    xs.Serialize(ms, FieldId);
    string xmlFieldid = UTF8Encoding.UTF8.GetString(ms.ToArray());
    xs.Serialize(ms, FieldId);
    string xmlStatusid = UTF8Encoding.UTF8.GetString(ms.ToArray());
    DataTable dtLangL2 = RetrievalProcedures.GetPartnerProfileIdforDashboardSearchLevel2(hdnL1toL2.Value, xmlClientid, xmlStatusid);
    chLanguageL2.Series["LangSeriesL2"].XValueMember = "FieldName";
    chLanguageL2.Series["LangSeriesL2"].YValueMembers = "cnt";
    chLanguageL2.DataSource = dtLangL2;
    chLanguageL2.DataBind();
}

そして、これはデータベースにパラメーターを渡すコードです

      public static DataTable GetPartnerProfileIdforDashboardSearchLevel2(System.String language, System.String clientId, System.String statusProId)
    {
        // create parameters
        SqlParameter[] parameters = new SqlParameter[3];
        parameters[0] = new SqlParameter("@Language", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "",  DataRowVersion.Current, language);
        parameters[1] = new SqlParameter("@ClientId", SqlDbType.Xml, 2147483647, ParameterDirection.Input, true, 0, 0, "",  DataRowVersion.Current, clientId);
        parameters[2] = new SqlParameter("@StatusProId", SqlDbType.Xml, 2147483647, ParameterDirection.Input, true, 0, 0, "",  DataRowVersion.Current, statusProId);

        // Call the stored proc.
        DataTable toReturn = new DataTable("GetPartnerProfileIdforDashboardSearchLevel2");
        bool hasSucceeded = DbUtils.CallRetrievalStoredProcedure("[JobApplicationModule].[dbo].[sp_GetPartnerProfileIdforDashboardSearchLevel2]", parameters, toReturn, null);

        return toReturn;
    }
4

1 に答える 1