1.1.2 ADO.NET模型

源代码:13033480群共享

1.1.2 ADO.NET模型

一、新建解决方案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

你可能感兴趣的:(.net)