在Mobile使用企业类库
Mobile中一个页里面可以包含多个Form,利用它来实现页之间的装换
1 在Web.Config中配置
<configSections>
<section name="datacfg" type="Micrsoft.Practices.EnterpriseLibrary.data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<connectionStrings>
<add name="connstr" connectionString="Data Source=(local);......."/>
</connectionStrings>
<datacfg defaultDatabase="connstr"/>
2 使用
using Microsoft.Practies.EnterpriseLibrary.Data;
private DataSet getUserDataSet()
{
DataBase db=DataBaseFactory.CreateDataBase();
DbCommand cmd=db.GetSqlStringCommand("select * from user");
return db.ExecuteDataSet(cmd);
}
protected void ObjectList_ItemCommand(object sender,ObjectListCommandEventArgs e)
{
switch(e.CommandName)
{
case "Edit":
....方法
ActiveForm=Form2;//激活Form2表单
default:
creak;
}
}
//对数据库进行操作
private void UpdateUser(string username,string pwd)
{
DataBase db=DataBaseFactory.CreateDataBase();
string cmd="update user set pwd=@pwd where username=@username";
DbCommand cmd=db.GetSqlStringCommand(cmd);
db.AddInParameter(cmd,"@pwd",DaType.String,pwd);
db.AddInParameter(cmd,"@username",DaType.String,username);
db.ExecuteNonQuery(cmd);
}