日期:2014-05-18  浏览次数:20559 次

用户注册数据不能加到数据库
页面是正常的,但是用户数据不能加到数据库中,这是代码,请大家帮看一下,有错没有.


strSQL   =   "Insert   into   person   (Name,Password,Mail)   Values( "
+   " ' "   +   this.Name   +   " ', "
+   " ' "   +   Functions.Encrypt(this.Password,1)   +   " ', "
+   " ' "   +   this.Mail   +   " ') ";

try
{
ExecuteSql(strSQL);
}
catch
{
throw   new   Exception( "Register   FAILED! ");
}

------解决方案--------------------
首先你确定你传的参数都有值嘛?
Insert into person (Name,Password,Mail) Values( "
+ " ' " + this.Name + " ', "
+ " ' " + Functions.Encrypt(this.Password,1) + " ', "
+ " ' " + this.Mail + " ') ";
如果参数没问题的话。把你的ExecuteSql(strSQL);函数拿出来看看。。。
------解决方案--------------------
SQL里怎么那么多引号啊
------解决方案--------------------
strSQL = "Insert into person (Name,Password,Mail) Values(@Name,@Password,@Mail) "
建议你这样写
------解决方案--------------------
Functions.Encrypt(this.Password,1) 这是什么啊
------解决方案--------------------
调试,看看生成的语句,然后查询分析看看
------解决方案--------------------
sql执行了吗?
------解决方案--------------------


是access数据库? 如果是的话,你看看是不是文件权限问题。加上everyone可写权限


或者把详细错误信息贴上来



------解决方案--------------------
Insert into person (Name,Password,Mail) Values( " ' "+ this.Name + " ', ' "+ Functions.Encrypt(this.Password,1) + " ', ' "+ this.Mail + " ' ")
用这个试一下
------解决方案--------------------


这样,你直接去掉 try.... catch,看看弹出的黄色错误页面,把信息粘过来看看



------解决方案--------------------
SQL的话,设个断点,得到你的命令
然后在查询分析器里执行一下看看