添加引用
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
//执行数据库操作:
Database db = DatabaseFactory.CreateDatabase();
//执行存储过程
DbCommand cmd = db.GetStoredProcCommand("存储过程名");
//执行Sql语句
DbCommand cmd = db.GetSqlStringCommand(sql);
db.AddInParameter(cmd, "物品编号", DbType.String, ProductID);
object ojb = db.ExecuteScalar(cmd);
例如:
public void AdLoadByQualification(string _AdLoadByQualification, string _Order)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmdTxt = db.GetStoredProcCommand("Ad_LoadByQualification");
db.AddInParameter(cmdTxt, "@AdLoadByQualification", DbType.String, _AdLoadByQualification);
db.AddInParameter(cmdTxt, "@AdLoadByQualification", DbType.String, _Order);
db.ExecuteNonQuery(cmdTxt);
}
http://blog.csdn.net/vipxiaotian/article/details/4409436