単純な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
}
}
}
}
エラーは画像をご覧ください:
ありがとう。