当前上下文不存在sex,qq
public override System.Web.Security.MembershipUser CreateUser(
string username,
string password,
string email,
string qq,
string sex,
string passwordQuestion,
string passwordAnswer,
bool isApproved,
object providerUserKey,
out System.Web.Security.MembershipCreateStatus status)
{
IDataAccessLayer.IUser dal
= new SQLServerDAL.User();
//调用数据访问的方法,将用户数据保存到数据库中
int userid=dal.SaveUser(username,password,sex,email,qq);
//用户创建的状态 也可以再写其他的
status = System.Web.Security.MembershipCreateStatus.Success;
//以下的是必须要写的,是这个类的返回,把这个用户信息返回来
System.Web.Security.MembershipUser user
=new System.Web.Security.MembershipUser (
"liuyanban" , //是name可以自己随便起的
username,
userid,
email,
string.Empty,
string.Empty,
true,
false,
DateTime.Now,
DateTime.Now,
DateTime.Now,
DateTime.Now,
DateTime.Now
);
return user;
}
//////////////////////////////////////////////
错误提示:
当前上下文不存在sex;
当前上下文不存在qq;
------解决方案--------------------
你这代码看着好混乱啊
private const string SaveUserSQL
= "insert into [user](username, userpassword, sex, email, qq) values (@username, @userpassword, @sex, @email, @qq); select SCOPE_IDENTITY()"; //select SCOPE_IDENTITY()查询id标示符的很重要
user是关键字,需要加[]