我试图创建一个Web服务,但是我在运行它时始终得到System.Data.SqlClient.SqlException
公共类Service1:IService1 { //连接字符串 私有字符串conStr =“数据源= .;初始目录= NblcAppTrial; uid = sa; pwd = admin @ 123”;
public List<SName> GetStudName()
{
List<SName> studentlist = new List<SName>();
SqlConnection connection = new SqlConnection(this.conStr);
connection.Open(); **//ERROR OCCURS HERE//**
SqlCommand cmd = new SqlCommand("select SName from NblcApp.dbo.Student ", connection);
cmd.CommandType = CommandType.Text;
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
SName name = new SName();
name.Name = sdr["SName"].ToString();
studentlist.Add(name);
}
return studentlist.ToList();