DataBase类自己整理
1)
问:
db.GetStoredProcCommand()方法执行存储过程时不提示错误,数据库中也不添加数据,存储过程肯定没有问题,参数也没写错,先是存储过程的名字,然后是传递的存储过程的参数的赋值,请大家指教,代码如下:
Database db = DatabaseFactory.CreateDatabase();
db.GetStoredProcCommand("B_spDepartmentSave", this.tbDepName.Text.Trim(), null,
this.ddlMangerName.Text.Trim(), this.ddlParentDepName.Text.Trim());
答:
如果数据库使用Sql Server,那么请用Sql Server的事件探查器或者Sql Server Profile监控一下你的存储过程是否在数据库中执行了。
不过看你的代码,是不是缺少对command的调用啊,试试这样:
| 1 | Database db = DatabaseFactory.CreateDatabase(); |
| 2 | DbCommand depCmd = db.GetStoredProcCommand("B_spDepartmentSave", this.tbDepName.Text.Trim(), null , this.ddlMangerName.Text.Trim(), this.ddlParentDepName.Text.Trim()); |
| 3 | db.ExecuteNonQuery(depCmd); |
2)
Dtatbase类用于数据库管理,不用创建connection对象,以及实现了多数据库支持,支持SQl,Oracle等数据,封装的很好,比较方便使用,为以后的数据库迁移打下基础。

浙公网安备 33010602011771号