日期:2014-05-20  浏览次数:20860 次

用SqlHelper类为什么返回不了值呢?
string   adUrl   = " ";
int   spRst=0;

SqlParameter[]   parms   =   {
      new   SqlParameter( "@UserId ",   SqlDbType.Int,4),
      new   SqlParameter( "@UserIp ",   SqlDbType.NVarChar,50),
      new   SqlParameter( "@ReURL ",   SqlDbType.NVarChar,1000),
      new   SqlParameter( "@return ",   SqlDbType.Int,4)
      };
parms[0].Value   =   _userid;
parms[1].Value   =   GuestInfo.GetIP();
parms[2].Direction   =   ParameterDirection.Output;
parms[3].Direction   =   ParameterDirection.Output;

SqlHelper.ExecuteNonQuery(new   CONN(adDbName).ConnString, "Guest_User_SP ",parms);
adUrl = parms[2].Value.ToString();
spRst = (int)parms[3].Value;


执行时一说是没有实例对象~~

------解决方案--------------------
检查 GuestInfo,new CONN(adDbName).ConnString两处
------解决方案--------------------
估计是SqlHelper.ExecuteNonQuery(new CONN(adDbName).ConnString, "Guest_User_SP ",parms);有问题,SqlHelper.ExecuteNonQuery确定没错?
再来就看new CONN(adDbName).ConnString
------解决方案--------------------
我也想知道,我也遇到过同样的问题
------解决方案--------------------
public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) {
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}

注意: cmd.Parameters.Clear();

------解决方案--------------------
你不RETURN,怎么有返回值?