我有生产和开发服务器,都使用相同的数据库和代码。但是当它执行这部分代码时:
protected void Page_Load(object sender, System.EventArgs e)
{
//if the user related to a company or not
SqlConnection myConnection01 = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand myCommand01 = new SqlCommand("UserCompany", myConnection01);
myCommand01.CommandType = CommandType.StoredProcedure;
SqlParameter parameterUserCompany01 = new SqlParameter("@FromEmail", SqlDbType.NVarChar,100);
parameterUserCompany01.Value = Context.User.Identity.Name;
myCommand01.Parameters.Add(parameterUserCompany01);
SqlParameter parameterUserCompany02 = new SqlParameter("@CountUser", SqlDbType.Int);
parameterUserCompany02.Direction = ParameterDirection.Output;
myCommand01.Parameters.Add(parameterUserCompany02);
myConnection01.Open();
myCommand01.ExecuteReader();
生产服务器可以毫无问题地执行,但开发服务器会出现此错误:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
两个DB只有细微的差别。一个包括来自其他人的一些不同记录。但我尝试了相同的记录,它仍然显示错误。 我不知道如何调试此错误?
答案 0 :(得分:0)
我引用user1314404
我发现问题是有两个用户拥有相同的用户 数据库中的电子邮件地址。
导致问题的是那个。
在询问查询之前,请务必仔细检查数据库中的重复项(索引,键或要编制索引的列),尤其是当您有不同的结果时 不同的数据库。