当前位置: 首页 > news >正文

哈尔滨建站公司可以不使用备案的网站名吗

哈尔滨建站公司,可以不使用备案的网站名吗,网站的后期维护,深圳龙华区龙塘社区前言 鉴于企业库5.0已经发布正式版#xff0c;同时有广大读者的要求#xff08;臭屁一下#xff0c;o(∩_∩)o...#xff09;#xff0c;后面文章的内容和代码将基于Enterprise Library5.0和Unity2.0来写#xff0c;感谢大家的一贯支持。 正文 数据库访问模块都能实现哪些…  前言   鉴于企业库5.0已经发布正式版同时有广大读者的要求臭屁一下o(∩_∩)o...后面文章的内容和代码将基于Enterprise Library5.0和Unity2.0来写感谢大家的一贯支持。   正文   数据库访问模块都能实现哪些功能呢数据库访问模块抽象类你正在使用的数据库提供了一些列接口使得你可以更容易的实现常用的数据库访问功能。例如:使用Database类填充DataSet数据集用database类获取一个适当的Command实例然后调用database的ExecuteDataSet方法就可以填充数据集。不需要你调用DataAdapter的Fill方法。ExecuteDataSet方法管理数据库连接实现了填充数据集所需要的所有工作。使用类似的方法通过database类可以直接执行command可以获取一个DataReader实例可以用dataset中的数据更新数据库。模块也支持多个操作的事务如果失败的话可以回滚。   除了使用ADO.NET也能完成的常用功能以外模块还支持异步访问数据库只要数据支持。还可以返回客户端可以用LINQ查询的数据的序列对象形式。   使用数据访问模块的主要优点除了简化开发以外它使得你可以创建一种provider独立的应用可以很容易的更换不同的数据提供源。在大多数情况下除非你在代码中指定了数据库类型剩下的就是更改配置文件中的连接字符串配置节就可以了。不需要你修改代码中的sql查询和存储过程及其参数。   数据访问模块提供的常用方法   下面列出一些模块常用的获取数据、更新数据方法其中有一些和直接使用ADO.NET中的方法很相似。      方法 功能 ExecuteDataset创建加载返回数据集 LoadData加载数据到一个已经存在的数据集 UpdateDataSet使用已经存在的数据集更新数据库内容 填充一个数据集使用数据集更新数据库 ExecuteReader创建返回一个provider独立的DbDataReader实例 从数据库读取多行数据 ExecuteNonQuery执行command返回数据库受影响的行数可以通过output返回多个值 ExecuteScalar执行command返回单个值 执行command数据库命令对象 ExecuteSproAccessor使用存储过程返回一个客户端可以查询的序列对象 ExecuteSqlStringAccessor使用SQL语句返回一个客户端可以查询的序列对象 以序列对象的形式返回数据 ExecuteXmlReader返回xml格式的数据xmlReader类型这个只能用在SQL Server数据库通过SqlDatabase类调用Database类中没有这个方法。 获取xml格式数据只能用在SQL Server数据库 GetStoredProcCommand返回一个存储过程的数据库command对象 GetSqlStringCommand返回一个SQL语句的数据库command对象 创建一个Command对象 AddInParameter创建一个新的input参数并且加入command的参数集合 AddOutParameter创建一个新的output参数并且加入command的参数集合 AddParameter创建一个指定类型的参数并且加入command的参数集合 GetParameterValue以Object类型返回指定参数的值 SetParameterValue给指定参数赋值   处理command的参数 CreateConnection创建返回当前数据库的连接允许你通过这个链接初始化和管理数据库事务 处理数据库事务        如果你使用SqlDatabase类的话可以使用Begin和End类型的方法实现数据库异步操作。       如何使用数据库访问模块       1首先通过企业库的配置工具添加模块配置       2在代码中添加如下代码         代码 static Database defaultDB  null;static Database namedDB  null;// 从容器中获取默认的数据库对象// The actual concrete type is determined by the configuration settings.defaultDB  EnterpriseLibraryContainer.Current.GetInstanceDatabase();// 从容器中获取指定名称的数据库对象 namedDB EnterpriseLibraryContainer.Current.GetInstanceDatabase(ExampleDatabase);          如果你需要使用ExecuteXmlReader方法或者是需要使用SQL Server数据库对象的话可以用下面的代码。   代码 static SqlDatabase sqlServerDB  null;// Resolve a SqlDatabase object from the container using the default database.sqlServerDB  EnterpriseLibraryContainer.Current.GetInstanceDatabase()as SqlDatabase;// Assume the method GetConnectionString exists in your application and// returns a valid connection string.string myConnectionString  GetConnectionString();SqlDatabase sqlDatabase  new SqlDatabase(myConnectionString);         使用DataReader获取多行数据   代码 // Call the ExecuteReader method by specifying just the stored procedure name.using (IDataReader reader  namedDB.ExecuteReader(MyStoredProcName)){// Use the values in the rows as required.}// Call the ExecuteReader method by specifying the command type// as a SQL statement, and passing in the SQL statement.using (IDataReader reader  namedDB.ExecuteReader(CommandType.Text,SELECT TOP 1 * FROM OrderList)){// Use the values in the rows as required ‐ here we are just displaying them.DisplayRowValues(reader);}         根据参数获取多行数据         代码 using (IDataReader reader  defaultDB.ExecuteReader(ListOrdersByState,new object[] { Colorado })){// Use the values in the rows as required ‐ here we are just displaying them.DisplayRowValues(reader);}                     通过添加参数获取多行数据 代码 // Read data with a SQL statement that accepts one parameter.string sqlStatement  SELECT TOP 1 * FROM OrderList WHERE State LIKE state;// Create a suitable command type and add the required parameter.using (DbCommand sqlCmd  defaultDB.GetSqlStringCommand(sqlStatement)){defaultDB.AddInParameter(sqlCmd, state, DbType.String, New York);// Call the ExecuteReader method with the command.using (IDataReader sqlReader  namedDB.ExecuteReader(sqlCmd)){Console.WriteLine(Results from executing SQL statement:);DisplayRowValues(sqlReader);}}               代码 // Create a suitable command type and add the required parameter.using (DbCommand sprocCmd  defaultDB.GetStoredProcCommand(storedProcName)){defaultDB.AddInParameter(sprocCmd, state, DbType.String, New York);// Call the ExecuteReader method with the command.using (IDataReader sprocReader  namedDB.ExecuteReader(sprocCmd)){Console.WriteLine(Results from executing stored procedure:);DisplayRowValues(sprocReader);}}         以对象形式返回数据             上图是一个使用Accessor访问数据库返回对象形式的数据的过程。 未完待续。。。。。。。。。。。。。。。。。。。。。。。。  转载于:https://www.cnblogs.com/virusswb/archive/2010/05/14/Enterprise-Library-DataAccessBlock-3.html
http://www.huolong8.cn/news/181743/

相关文章:

  • 成都户外网站建设1688的网站特色
  • 重庆h5建站模板wordpress 纯净主题
  • 蛋白质结构预测工具网站开发厦门手机网站建设方案
  • wordpress插件主题集成北京网站优化济南兴田德润简介电话
  • 南京最好的网站设计公司做移动网站
  • 如何推广自己的个人网站呢东莞网站建设全过程
  • 怎么导入网站源码佳匠网站建设
  • 泰安建设网站制作自己的网站教程
  • 青岛响应式网站设计南通学校网站建设
  • 费县建设局网站做简报的网站
  • 网站建设都用哪些软件中国互联网公司排名2022
  • 佛山市住房和城乡建设部网站模具机械东莞网站建设
  • 酒店网站建设价格怎么做加盟网站
  • 银川做网站最好的公司有哪些免费找素材软件
  • 农机网站建设目标学校网站建设的不足
  • 网站建设概念wordpress与php
  • 网页制作网站创建公司宣传册ppt
  • 山东网站备案拍照wordpress 内网搭建
  • 驻马店标准网站建设wap网站建设如何改造熊掌号
  • 网站手机客户端开发中山网站搜索优化
  • 义乌做公司网站成都市网站开发公司服务
  • 南昌网站系统给网站做脚本算违法吗
  • 专业网站建设-好发信息网wordpress问题解决
  • 百度搜索不到公司网站成都微网站建设
  • 连锁酒店的网站建设盘龙网站建设公司
  • 哈尔滨网站推广wordpress视频曹鹏
  • 免费网站自动优化软件信息流广告代运营
  • 新昌网站建设wordpress 股票主题
  • android系统开发上海seo服务
  • 网站超市创可贴网站怎么做图片大全