有空的来看看···· c#操作sqlserver 存储过程是,参数类型是ParameterDirection.InputOutput,现在存储过程没问题,但是却不能返回值,请问这是什么原因? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是详细代码:private SqlConnection con = new SqlConnection(SQLHelper_Erp.sConnStr);bool isOK = true; int num = -1; con.Open(); SqlTransaction transaction = con.BeginTransaction(IsolationLevel.ReadCommitted); string MyProcedure = "procSaveDepartment"; SqlCommand cmd = new SqlCommand(MyProcedure, transaction.Connection); cmd.Transaction = transaction; try { SqlParameter[] Params = { SQLHelper_Erp .MakeInOutParam ("@DepartmentID",info.DepartmentID ,SqlDbType.Int,9), SQLHelper_Erp.MakeInParam ("@DepartmentCode",info.DepartmentCode ), SQLHelper_Erp.MakeInParam ("@DepartmentName",info.DepartmentName ), SQLHelper_Erp.MakeInParam ("@ParentDepartmentID",info.ParentDepartmentID ), SQLHelper_Erp.MakeInParam ("@deptTel",info.deptTel ), SQLHelper_Erp.MakeInParam ("@deptFax",info.deptFax ), SQLHelper_Erp.MakeInParam ("@DataStatus",info.DataStatus ), SQLHelper_Erp.MakeInParam ("@Create_UID",info.Create_UID ), SQLHelper_Erp.MakeInParam ("@Create_Date",info.Create_Date ), SQLHelper_Erp.MakeInParam ("@Update_UID",info.Update_UID ), SQLHelper_Erp.MakeInParam ("@Update_Date",info.Update_Date ), SQLHelper_Erp.MakeInParam ("@Disuse_UID",info.Disuse_UID ), SQLHelper_Erp.MakeInParam ("@Disuse_Date",info.Disuse_Date ), SQLHelper_Erp.MakeInParam ("@Re",info.Re ), }; foreach (SqlParameter parm in Params) cmd.Parameters.Add(parm); SQLHelper_Erp.ExecuteNonQuery(cmd); SQLHelper_Erp.ExecuteNonQuery(transaction, "delete from DepartmentList where DepartmentID=" + cmd.Parameters[0].Value.ToString () + ""); transaction.Commit(); con.Close(); isOK = true; } catch (SqlException ex) { transaction.Rollback(); con.Close(); isOK = false; } return isOK; 怎么写的设置parms[1].Direction=ParameterDirection.InputOutput;单步执行看看using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ToString())){conn.Open();SqlCommand MyCommand = new SqlCommand("", conn);MyCommand.CommandType = CommandType.StoredProcedure;MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int));MyCommand.Parameters["@a"].Value = 20;MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int));MyCommand.Parameters["@b"].Direction = ParameterDirection.Output;MyCommand.ExecuteNonQuery();Response.Write(MyCommand.Parameters["@b"].Value.ToString());} <global namespace> 包含与别名 Excel 冲突的定义 小妹 跪求解决办法! 后台绑定datalist中编辑模板中的项 [原创]逆向思维有时比较好.【讨论帖】 XML的新闻系统的困惑(2) 请listhome、 xiaohutushen、WUNEN进来接分 关于动态增加控件的问题 帮我转换下面一句asp语句 DATAGRID的问题!急 求一个MVC项目中导出数据到Excel表和将Excel中数据导入至数据库的实例 在线求助ASP.NET连接SQL aspnet_regsql
private SqlConnection con = new SqlConnection(SQLHelper_Erp.sConnStr);
bool isOK = true;
int num = -1;
con.Open();
SqlTransaction transaction = con.BeginTransaction(IsolationLevel.ReadCommitted); string MyProcedure = "procSaveDepartment";
SqlCommand cmd = new SqlCommand(MyProcedure, transaction.Connection);
cmd.Transaction = transaction; try
{
SqlParameter[] Params =
{
SQLHelper_Erp .MakeInOutParam ("@DepartmentID",info.DepartmentID ,SqlDbType.Int,9),
SQLHelper_Erp.MakeInParam ("@DepartmentCode",info.DepartmentCode ),
SQLHelper_Erp.MakeInParam ("@DepartmentName",info.DepartmentName ),
SQLHelper_Erp.MakeInParam ("@ParentDepartmentID",info.ParentDepartmentID ),
SQLHelper_Erp.MakeInParam ("@deptTel",info.deptTel ),
SQLHelper_Erp.MakeInParam ("@deptFax",info.deptFax ),
SQLHelper_Erp.MakeInParam ("@DataStatus",info.DataStatus ),
SQLHelper_Erp.MakeInParam ("@Create_UID",info.Create_UID ),
SQLHelper_Erp.MakeInParam ("@Create_Date",info.Create_Date ),
SQLHelper_Erp.MakeInParam ("@Update_UID",info.Update_UID ),
SQLHelper_Erp.MakeInParam ("@Update_Date",info.Update_Date ),
SQLHelper_Erp.MakeInParam ("@Disuse_UID",info.Disuse_UID ),
SQLHelper_Erp.MakeInParam ("@Disuse_Date",info.Disuse_Date ),
SQLHelper_Erp.MakeInParam ("@Re",info.Re ),
}; foreach (SqlParameter parm in Params)
cmd.Parameters.Add(parm); SQLHelper_Erp.ExecuteNonQuery(cmd); SQLHelper_Erp.ExecuteNonQuery(transaction, "delete from DepartmentList where DepartmentID=" + cmd.Parameters[0].Value.ToString () + ""); transaction.Commit();
con.Close();
isOK = true;
}
catch (SqlException ex)
{
transaction.Rollback();
con.Close();
isOK = false;
}
return isOK;
设置parms[1].Direction=ParameterDirection.InputOutput;
单步执行看看
using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ToString()))
{
conn.Open();
SqlCommand MyCommand = new SqlCommand("", conn);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int));
MyCommand.Parameters["@a"].Value = 20;
MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int));
MyCommand.Parameters["@b"].Direction = ParameterDirection.Output;
MyCommand.ExecuteNonQuery();
Response.Write(MyCommand.Parameters["@b"].Value.ToString());
}