Reputation:
I have a simple WCF application. In the file IService.cs:
namespace WcfService1
{
[ServiceContract]
public interface IService
{
[OperationContract]
List<ActiveSP> GetActiveSP();
}
[DataContract]
public class ActiveSP
{
[DataMember]
public string DESCR { get; set; }
}
}
In the file 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
}
}
}
}
The error please see the image:
Thanks.
Upvotes: 0
Views: 52
Reputation: 180947
You can't call a variable 1stSP, the first character in a variable name needs to be a letter or an underscore, not a number.
Here is some more information on valid identifiers
Upvotes: 2
Reputation: 2053
rename 1spSP to firstSP or something like that :) Identifiers can't start with numbers.
Upvotes: 0
Reputation: 8818
You can't start a variable name with a number. That's what's throwing it off.
Upvotes: 0