读书人

“System.Data.dll”类型的错误 高手来

发布时间: 2012-11-04 10:42:42 作者: rapoo

“System.Data.dll”类型的异常 高手来
string sql2 = "update [WebGameUserDB].[dbo].[saving_card_number] set state= a where saving_card_pwd='" + cardPwd + "')"; 在 System.Data.SqlClient.SqlException 中第一次偶然出现的“System.Data.dll”类型的异常

怎么看SQL2也没写错啊。。
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using DBExcute;

namespace xiyangyang
{
public partial class chongzhicard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(chongzhicard));
}
[AjaxPro.AjaxMethod]
public int checkCode(string code)
{
if (code == Session["checkCode"].ToString())
{
return 0;
}
else
{
return 1;
}
}
[AjaxPro.AjaxMethod]
public int checkRegName(string regName)
{
string strCheckRegName = "select count(*) from [QPGameUserDB].[dbo].[AccountsInfo] where Accounts ='" + regName + "'";

return DataBaseSql.RunExecuteScalar(strCheckRegName);

}
[AjaxPro.AjaxMethod]
public int CardChongZhi(string userName, string cardId, string cardPwd)
{
SqlParameter[] paras ={ new SqlParameter("@cardnumber", SqlDbType.VarChar,100),
new SqlParameter("@cardpwd",SqlDbType.VarChar,100)


};
paras[0].Value = cardId;
paras[1].Value = cardPwd;
int checkCard = DBExcute.DataBase.RunExecuteScalar("Check_Card_Use_Status", paras);
if (checkCard == 4)
{
DataBLL.Filter filter = new DataBLL.Filter();
DataTable dt = filter.GetParas();
int bili = Convert.ToInt32(dt.Rows[0]["setBili"].ToString());
int SetSendBili = Convert.ToInt32(dt.Rows[0]["SetSendBili"]);
int money = Convert.ToInt32(dt.Rows[0]["setSendMoney"]);
SqlParameter[] chongzhiparas ={
new SqlParameter("@cardnumber", SqlDbType.VarChar,100),
new SqlParameter("@cardpwd", SqlDbType.VarChar,100),
new SqlParameter("@username", SqlDbType.VarChar,100),
new SqlParameter("@time",DateTime.Now),
new SqlParameter("@bili",bili)
};

chongzhiparas[0].Value = cardId;
chongzhiparas[1].Value = cardPwd;
chongzhiparas[2].Value = userName;

string sql = "select saving_card_type from [WebGameUserDB].[dbo].[saving_card_type] where saving_card_type_id in (select saving_card_type from [WebGameUserDB].[dbo].[saving_card_number] where saving_card_number='" + cardId + "')";
int point = 0;

using (DataTable table = DBHelper.GetDataSet(sql))
{
point = Convert.ToInt32(table.Rows[0][0]);


}


int zengsong = point * bili * (SetSendBili) / 100;
string sql1 = "update [QPTreasureDB].[dbo].[GameScoreInfo] set Score=Score+" + zengsong + " where UserID in (select UserID from [QPGameUserDB].[dbo].[AccountsInfo] where Accounts='" + userName + "')";
DBHelper.ExecuteCommand(sql1);
int a = 3;
string sql2 = "update [WebGameUserDB].[dbo].[saving_card_number] set state= a where saving_card_pwd='" + cardPwd + "')";

DBHelper.ExecuteCommand(sql2);
return 1;


}
else if (checkCard == 3)
{
return 3; //该卡已经被使用过,不能在使用

}
else
{
return 2; //对不起,卡密码输入错误
}

}

}
}


[解决办法]
string sql2 = "update [WebGameUserDB].[dbo].[saving_card_number] set state= a where saving_card_pwd='" + cardPwd + "')";

多了)

改成
string sql2 = "update [saving_card_number] set state= " + a + " where saving_card_pwd='" + cardPwd + "'";
[解决办法]
去掉表前面的[数据库名].[账户]

直接表名就可以了。

读书人网 >asp.net

热点推荐