int influencingRows = 0;
string procedureName = "updateSalary";
Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase sql;
influencingRows = sql.ExecuteNonQuery( procedureName, null);
// SqlCommand cmd = new SqlCommand("select * fdf");
try
{
influencingRows = sql.ExecuteNonQuery(
}
catch (Exception exceptions)
{ MessageBox.Show(exceptions.ToString());//注释
//Console.WriteLine(exceptions.ToString()); }
我用上面的执行我的存储过程.是不是要先打开连接. 然后再执行存储过程是吧.
另外要得到影响的行数.
要求是用Enterprise Library 4.1 - October 2008
string connString = System.Web.Configuration.
WebConfigurationManager.ConnectionStrings
["AdventureWorksDB"].ConnectionString;
SqlDatabase db = new SqlDatabase(connString);
string sqlCommand = "Select " + "EmployeeID,
NationalIDNumber," + "LoginID, Title from " +
" HumanResources.Employee ";
DbCommand dbCommand = db.GetSqlStringCommand
(sqlCommand);
DataSet dst = db.ExecuteDataSet(dbCommand);
gridEmployees.DataSource =
dst.Tables[0].DefaultView;
gridEmployees.DataBind();