DAL层中出现找不到可接受的类型
--------------------------------DAL层---------------publicstaticpartialclassEntPopedom...
--------------------------------DAL层---------------
public static partial class EntPopedomService
{
public static EntPopedom AddEntPopedom(EntPopedom entPopedom)
{
string sql =
"INSERT entPopedom (popName)" +
"VALUES (@popName)";
sql += " ; SELECT @@IDENTITY";
try
{
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@popName", entPopedom.popName)
};
int newId = DBHelper.GetScalar(sql, para);
return GetEntPopedomByID(newId);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
------------------Model层------------
namespace Car.Models
{
public class EntPopedom
{
private int iD;
private string popName = String.Empty;
public EntPopedom() { }
public int ID
{
get { return this.iD; }
set { this.iD = value; }
}
public string PopName
{
get { return this.popName; }
set { this.popName = value; }
}
}
}
已经引用了Model层的命名空间了,我把
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@popName", entPopedom.popName)
};
这段代码注释了,就不报错了,我现在不知道为什么会这样,
我用的是Vs2008 + SQL server2005 展开
public static partial class EntPopedomService
{
public static EntPopedom AddEntPopedom(EntPopedom entPopedom)
{
string sql =
"INSERT entPopedom (popName)" +
"VALUES (@popName)";
sql += " ; SELECT @@IDENTITY";
try
{
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@popName", entPopedom.popName)
};
int newId = DBHelper.GetScalar(sql, para);
return GetEntPopedomByID(newId);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
------------------Model层------------
namespace Car.Models
{
public class EntPopedom
{
private int iD;
private string popName = String.Empty;
public EntPopedom() { }
public int ID
{
get { return this.iD; }
set { this.iD = value; }
}
public string PopName
{
get { return this.popName; }
set { this.popName = value; }
}
}
}
已经引用了Model层的命名空间了,我把
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@popName", entPopedom.popName)
};
这段代码注释了,就不报错了,我现在不知道为什么会这样,
我用的是Vs2008 + SQL server2005 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询