Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF文件出错_C#_Wcf - Fatal编程技术网

C# WCF文件出错

C# WCF文件出错,c#,wcf,C#,Wcf,我有一个简单的WCF应用程序。在IService.cs文件中: namespace WcfService1 { [ServiceContract] public interface IService { [OperationContract] List<ActiveSP> GetActiveSP(); } [DataContract] public class ActiveSP { [DataMember]

我有一个简单的WCF应用程序。在IService.cs文件中:

namespace WcfService1
{
   [ServiceContract]
   public interface IService
   {
       [OperationContract]
       List<ActiveSP> GetActiveSP();
   }

  [DataContract]
  public class ActiveSP
  {
     [DataMember]
     public string DESCR { get; set; }
  }
}
在文件Service.svc.cs中:

namespace WcfService1
{
   public class Service : IService
   {
      SqlConnection Conn;
      SqlCommand Cmd;
      public Service()
      {
         Conn = new SqlConnection("Data Source=myweb;Initial Catalog=PeopleSoft;Integrated Security=True;");
      }

     public List<ActiveSP> GetActiveSP()
     {
        Conn.Open();
        Cmd = new SqlCommand();
        Cmd.Connection = Conn;
        Cmd.CommandText = "Select DESCR from myTable"; // return column (varchar type) 
        SqlDataReader Reader = Cmd.ExecuteReader();
        List<ActiveSP> 1stSP = new List<ActiveSP>(); // wrong here
        while (Reader.Read())
        {
            // blah
         }
      }
   }
 }
错误请参见图片:

谢谢。

您不能调用变量1stSP,变量名称中的第一个字符必须是字母或下划线,而不是数字


变量名不能以数字开头。这就是为什么要放弃它。

将1SPP重命名为firstSP或类似的名称:
标识符不能以数字开头。

我敢肯定,变量名不能以数字C开头。

对不起,我应该小心介于l和1之间。