EntLib5.0 DAAB(Data Access Application Block),数据访问程序块
企业库下载:(还有相关视频及帮助文档) http://entlib.codeplex.com/ Entlib5.0 要求.net framework3.5 sp1,或 .net framework 4.0 App.config: ?xml version="1.0" encoding="utf-8" ?configuration configdivs div name="dataConfiguration" type="Micro
企业库下载:(还有相关视频及帮助文档)
http://entlib.codeplex.com/
Entlib5.0 要求.net framework3.5 sp1,或 .net framework 4.0
App.config:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configdivs> <div name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirepermission="true"></div> </configdivs> <dataconfiguration defaultdatabase="DbConnString"></dataconfiguration> <connectionstrings> <add name="DbConnString" connectionstring="Data Source=myip;Initial Catalog=Test;User Id=sa;Password=MyPwd;" providername="System.Data.SqlClient"></add> <add name="DbConnString182" connectionstring="Data Source=myAnotherIP;Initial Catalog=DbName;User Id=User;Password=MyPwd" providername="System.Data.SqlClient"></add> </connectionstrings> </configuration>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Practices.EnterpriseLibrary.Data; using Microsoft.Practices.EnterpriseLibrary.Data.Sql; using System.Data.Common; using System.Data; namespace TestEntLib5_0InFramework3_5 { class Program { static void Main(string[] args) { Database db = DatabaseFactory.CreateDatabase(); //创建一个默认的数据库对象 //Database db = DatabaseFactory.CreateDatabase("DbConnString182"); //创建一个命名的数据库对象 //1.ExecuteNonQuery /* DbCommand dbCmd = db.GetSqlStringCommand( @"INSERT INTO T_EntLib (name,birthday,email) VALUES(N'吴1','2008-12-23','a@qq.com'); INSERT INTO T_EntLib (name,birthday,email) VALUES(N'吴2','2008-12-23','gga@qq.com'); INSERT INTO T_EntLib (name,birthday,email) VALUES(N'吴3','2008-12-23','a@qq.com'); INSERT INTO T_EntLib (name,birthday,email) VALUES(N'吴4','2008-12-23','a@qq.com'); INSERT INTO T_EntLib (name,birthday,email) VALUES(N'吴5','2008-12-23','a@qq.com');"); int iAffectedNum = db.ExecuteNonQuery(dbCmd); //返回影响的条数 Console.WriteLine(iAffectedNum); */ //2. ExecuteDataSet自动开启关闭Connection //var sql = "SELECT TOP 10 * FROM sys_draw ORDER BY id DESC"; /* var sql = "SELECT * FROM T_EntLib"; DbCommand cmd = db.GetSqlStringCommand(sql); // No need to open the connection; just make the call. // 执行时监视:cmd.Connection.State DataSet ds = db.ExecuteDataSet(cmd); //在此处发现:cmd.Connection.State Closed System.Data.ConnectionState //说明自动关闭连接 Console.WriteLine(ds.Tables[0].Rows.Count); int col = ds.Tables[0].Columns.Count; foreach (DataRow dr in ds.Tables[0].Rows) { for (int i = 0; i (sql); //使用默认的RowMapper IRowMapper rowMapper = MapBuilder<info>.MapAllProperties() .MapByName(x => x.NAME) .DoNotMap(x => x.Email) .DoNotMap(x=>x.Birthday) .Build(); var result = db.ExecuteSqlStringAccessor<info>(sql, rowMapper); //使用自定义的RowMapper foreach (var item in result) { Console.WriteLine("ID={0},Name:{1},Birthday:{2},Email:{3}", item.Id, item.NAME, item.Birthday, item.Email); } Console.ReadKey(); } } } </info></info>
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestEntLib5_0InFramework3_5 { public class Info { public int Id { get; set; } public string NAME { get; set; } public string Email { get; set; } public DateTime Birthday { get; set; } } }
CREATE TABLE T_EntLib ( ID bigint IDENTITY, NAME nvarchar(50), Birthday datetime, Email varchar(50) )
http://files.cnblogs.com/wucg/TestEntLib5_0InFramework3_5.zip

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

SQL IF statements are used to conditionally execute SQL statements, with the syntax as: IF (condition) THEN {statement} ELSE {statement} END IF;. The condition can be any valid SQL expression, and if the condition is true, execute the THEN clause; if the condition is false, execute the ELSE clause. IF statements can be nested, allowing for more complex conditional checks.

The advantage of multithreading is that it can improve performance and resource utilization, especially for processing large amounts of data or performing time-consuming operations. It allows multiple tasks to be performed simultaneously, improving efficiency. However, too many threads can lead to performance degradation, so you need to carefully select the number of threads based on the number of CPU cores and task characteristics. In addition, multi-threaded programming involves challenges such as deadlock and race conditions, which need to be solved using synchronization mechanisms, and requires solid knowledge of concurrent programming, weighing the pros and cons and using them with caution.

The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

How to avoid the third-party interface returning 403 error in the Node environment. When calling the third-party website interface using Node.js, you sometimes encounter the problem of returning 403 error. �...

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

Methods to solve the cross-domain problem of Vue Axios include: Configuring the CORS header on the server side using the Axios proxy using JSONP using WebSocket using the CORS plug-in

Get ComponentVerify in EasyWechat5.5...

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.
