DatabaseFactory.CreateDatabase 方法操作数据库
Posted 如若
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DatabaseFactory.CreateDatabase 方法操作数据库相关的知识,希望对你有一定的参考价值。
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
string sql = "";
//程序启动的时候 Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand(sql); db.AddInParameter(dbCommand, "@MenuId", DbType.Int32, menuId); db.AddOutParameter(dbCommand, "@Result", DbType.Int32, Int32.MaxValue); db.AddOutParameter(dbCommand, "@ResultMessage", DbType.AnsiString, 1000); db.ExecuteNonQuery(dbCommand);
<dataConfiguration defaultDatabase="SqlConnection" /> <connectionStrings> <add name="SqlConnection" connectionString="User ID=sa;Initial Catalog=test;Data Source=192.168.1.100\test;[email protected];" providerName="System.Data.SqlClient" /> </connectionStrings>
以上是关于DatabaseFactory.CreateDatabase 方法操作数据库的主要内容,如果未能解决你的问题,请参考以下文章