C# 值'';根据其数据类型';http://www.w3.org/2001/XMLSchema'

C# 值'';根据其数据类型';http://www.w3.org/2001/XMLSchema',c#,.net,xml,C#,.net,Xml,我是一个新手,在这里学习XML编程……我创建了一个上载XML文件的函数……在上载XML(这是带有用户数据的简单问答数据)时,验证函数抛出异常 e、 Message=“id”元素无效-值“43516”无效 根据其数据类型无效 “”-字符串“43516”不是 有效的Int16值。“ 这是我的职责 [WebMethod] public static bool CheckFile(string filename) {

我是一个新手,在这里学习XML编程……我创建了一个上载XML文件的函数……在上载XML(这是带有用户数据的简单问答数据)时,验证函数抛出异常

e、 Message=“id”元素无效-值“43516”无效 根据其数据类型无效 “”-字符串“43516”不是 有效的Int16值。“

这是我的职责

  [WebMethod]
            public static bool CheckFile(string filename)
            {

                    surgeProtection = true;
                    bool returnval = false;
                    String xsdPath = "";
                    //Read the path to upload on the web server
                    string Uploadpath = ConfigurationManager.AppSettings["UploadPath"];
                    xsdPath = Uploadpath + "\\" + "survey.xsd";

                    ////Validate the uploaded files on the web server

                    XmlSchemaSet schemas = new XmlSchemaSet(); //intialize schema class
                    using (FileStream schemastream = File.OpenRead(xsdPath)) //xsd file load
                    {
                        schemas.Add(XmlSchema.Read(schemastream, new ValidationEventHandler(OnValidate)));
                            //create event for schema
                    }
                    schemas.Compile();

                    String xmlPath = filename;
                    xmlPath = Uploadpath + "\\" + filename;


                    XmlDocument doc = new XmlDocument();
                     byte[] mybyte = Dashboard.Model.Surveys.SurveyService.GetImageFromDB(filename);
                    string xml = Encoding.UTF8.GetString(mybyte);
                    doc.LoadXml(xml);


                    doc.Schemas = schemas; // take schema
                    doc.Validate(OnValidate); // validate schema

                    returnval = surgeProtection;
                    return returnval;

                }



This is my validation Function

        public static void OnValidate(object sender, ValidationEventArgs e)
            {

         switch (e.Severity)
            {
                case XmlSeverityType.Error:

                    surgeProtection = false;
                    sw.WriteLine("Error: " + e.Message);
            }
            }

this is my xml

    <?xml version="1.0" encoding="utf-8"?>
    <survey>
        <title>xxxxxxxxxx</title>
        <questions>
            <question>
                <description>TestDescription</description>
                <type>grid</type>
                <id>43516</id>
                <options>
                    <option value="0">0</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                </options>
                <sub-question description="-" id="43516_01">
                    <response>
                        <answer user="xxxx@xxx.com">7</answer>

                    </response>
                </sub-question>
            </question>
        ..and so on questions
        </questions>
        <users>
            <user iRecipientId="" sEmail="xxxx" city="xx" country="xx" responseDate="xxx"/>

        ..and so on
        </users>
    </survey>
XML非常大…但我刚刚展示了基本格式。。。据我所知,托波姆的专栏是43516 abd suqestion

我需要分配什么数据类型,我需要在哪里更改数据类型??。我需要在DB表中更改吗?在SQL中,数据类型是int或bigint…不是short..long..我需要更改为bigint吗?
任何建议都会很有帮助

检查您的模式中定义了什么id。我猜它将被定义为short,您需要将其更改为int。或者使用一个短范围的id值


请参见

我在将Visual Studio 2005项目升级到VS2010时收到了这些警告

警告1“IsAppSettingsProperty”属性无效-值“False”根据其数据类型“”无效-字符串“False”不是有效的布尔值


当我根据上面列出的URL查看XMLSxhema时,我发现True | False是区分大小写的。我用所有小写的true | false替换了那些警告位置布尔值。警告已全部消失。

此错误已重新解决…架构中有元素…显示错误…我将其更改为“long”,错误已解决…但另一个错误出现…“未声明'id'属性”。…我需要在哪里进一步更改“id”?
ID          int         Unchecked
ImageName   varchar(200)    Unchecked
Image   varbinary(MAX)  Unchecked