• 1.1.2 ADO.NET模型


    源代码:13033480群共享

    一、新建解决方案MyADOdotNET

    二、在解决方案中添加类库项目Data,设置属性。

    三、在类库Data中添加类Data.cs

    四、在Data.cs中添加代码:

    namespace WestGarden.Data
    {
        namespace SqlClient
        {
            public class SqlConnection
            {
                public string Information = "WestGarden.Data.SqlClient.SqlConnection";
            }
            public class SqlCommand
            {
                public string Information = "WestGarden.Data.SqlClient.SqlCommand";
            }
            public class SqlDataReader
            {
                public string Information = "WestGarden.Data.SqlClient.SqlDataReader";
            }
            public class SqlDataAdapter
            {
                public string Information = "WestGarden.Data.SqlClient.SqlDataAdapter";
            }
        }
    
        namespace OleDb
        {
            public class OleDbConnection
            {
                public string Information = "WestGarden.Data.OleDb.OleDbConnection";
            }
            public class OleDbCommand
            {
                public string Information = "WestGarden.Data.OleDb.OleDbCommand";
            }
            public class OleDbDataReader
            {
                public string Information = "WestGarden.Data.OleDb.OleDbDataReader";
            }
            public class OleDbDataAdapter
            {
                public string Information = "WestGarden.Data.OleDb.OleDbDataAdapter";
            }
        }
        
        namespace Odbc
        {
            public class OdbcConnection
            {
                public string Information = "WestGarden.Data.Odbc.OdbcConnection";
            }
            public class OdbcCommand
            {
                public string Information = "WestGarden.Data.Odbc.OdbcCommand";
            }
            public class OdbcDataReader
            {
                public string Information = "WestGarden.Data.Odbc.OdbcDataReader";
            }
            public class OdbcDataAdapter
            {
                public string Information = "WestGarden.Data.Odbc.OdbcDataAdapter";
            }
        }
       
        namespace OracleClient
        {
            public class OracleConnection
            {
                public string Information = "WestGarden.Data.OracleClient.OracleConnection";
            }
            public class OracleCommand
            {
                public string Information = "WestGarden.Data.OracleClient.OracleCommand";
            }
            public class OracleDataReader
            {
                public string Information = "WestGarden.Data.OracleClient.OracleDataReader";
            }
            public class OracleDataAdapter
            {
                public string Information = "WestGarden.Data.OracleClient.OracleDataAdapter";
            }
        }
    }
    


     

    五、在解决方案中添加网站项目Web

    六、在Default.aspx.cs中添加代码:

    using System;

     

    using WestGarden.Data.SqlClient;

    using WestGarden.Data.OleDb;

    using WestGarden.Data.Odbc;

    using WestGarden.Data.OracleClient;

     

    namespace WestGarden.Web

    {

        public partial class Default : System.Web.UI.Page

        {

            protected void Page_Load(object sender, EventArgs e)

            {

                Response.Write("SQLServer.NET数据提供程序核心类有4个,分别是:</br>");

                SQLServer();

     

                Response.Write("OleDb.NET数据提供程序核心类有4个,分别是:</br>");

                OleDb();

     

                Response.Write("Odbc.NET数据提供程序核心类有4个,分别是:</br>");

                Odbc();

     

                Response.Write("Oracle.NET数据提供程序核心类有4个,分别是:</br>");

                Oracle();

            }

            void SQLServer()

            {

                SqlConnection conn = new SqlConnection();

                SqlCommand cmd = new SqlCommand();

                SqlDataReader rdr = new SqlDataReader();

                SqlDataAdapter da = new SqlDataAdapter();

     

                Response.Write(conn.Information + "</br>");

                Response.Write(cmd.Information + "</br>");

                Response.Write(rdr.Information + "</br>");

                Response.Write(da.Information + "</br></br>");

            }

            void OleDb()

            {

                OleDbConnection conn = new OleDbConnection();

                OleDbCommand cmd = new OleDbCommand();

                OleDbDataReader rdr = new OleDbDataReader();

                OleDbDataAdapter da = new OleDbDataAdapter();

     

                Response.Write(conn.Information + "</br>");

                Response.Write(cmd.Information + "</br>");

                Response.Write(rdr.Information + "</br>");

                Response.Write(da.Information + "</br></br>");

            }

            void Odbc()

            {

                OdbcConnection conn = new OdbcConnection();

                OdbcCommand cmd = new OdbcCommand();

                OdbcDataReader rdr = new OdbcDataReader();

                OdbcDataAdapter da = new OdbcDataAdapter();

     

                Response.Write(conn.Information + "</br>");

                Response.Write(cmd.Information + "</br>");

                Response.Write(rdr.Information + "</br>");

                Response.Write(da.Information + "</br></br>");

            }

     

            void Oracle()

            {

                OracleConnection conn = new OracleConnection();

                OracleCommand cmd = new OracleCommand();

                OracleDataReader rdr = new OracleDataReader();

                OracleDataAdapter da = new OracleDataAdapter();

     

                Response.Write(conn.Information + "</br>");

                Response.Write(cmd.Information + "</br>");

                Response.Write(rdr.Information + "</br>");

                Response.Write(da.Information + "</br></br>");

            }

        }

    }

    版权所有©2012,西园电脑工作室.欢迎转载,转载请注明出处.更多文章请参阅博客http://blog.csdn.com/yousuosi

  • 相关阅读:
    html5本地存储之localstorage 、本地数据库、sessionStorage简单使用示例
    HTMl5的存储方式sessionStorage和localStorage详解
    浏览器文档模式设置
    页面缓存
    SQL Server死锁总结
    读写分离,读写分离死锁解决方案,事务发布死锁解决方案,发布订阅死锁解决方案
    页面缓存
    HTML5 history API,创造更好的浏览体验
    【转】编写高质量代码改善C#程序的157个建议——建议96:成员应优先考虑公开基类型或接口
    【转】编写高质量代码改善C#程序的157个建议——建议95:避免在构造方法中调用虚成员
  • 原文地址:https://www.cnblogs.com/java20130723/p/3211638.html
Copyright © 2020-2023  润新知