Compare connection: metadata (C#) : Connection Compare « ADO.net Database « ASP.Net

ASP.Net
1. ADO.net Database
2. Ajax
3. Asp Control
4. Collections
5. Components
6. Data Binding
7. Development
8. File Directory
9. HTML Control
10. Language Basics
11. Login Security
12. Mobile Control
13. Network
14. Page
15. Request
16. Response
17. Server
18. Session Cookie
19. Sitemap
20. Theme Style
21. User Control and Master Page
22. Validation by Control
23. Validation by Function
24. WebPart
25. WPF
26. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.Net » ADO.net Database » Connection Compare 
Compare connection: metadata (C#)

<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data.Odbc" %>
<script runat="server">

    void Page_Load(object sender, EventArgs e) {
        SqlConnection mySqlConnection = new SqlConnection("Data Source=whsql-v08.prod.mesa1.secureserver.net;Initial Catalog=DB_49907;User ID=java2suser;Password='password';");

        mySqlConnection.Open();
    
        lblSqlConnectionString.Text = mySqlConnection.ConnectionString;
        lblSqlConnectionTimeout.Text = Convert.ToString(mySqlConnection.ConnectionTimeout);
        lblSqlDatabase.Text = mySqlConnection.Database;
        lblSqlDataSource.Text = mySqlConnection.DataSource;
        lblSqlPacketSize.Text = Convert.ToString(mySqlConnection.PacketSize);
        lblSqlServerVersion.Text = mySqlConnection.ServerVersion;
        lblSqlState.Text = Convert.ToString(mySqlConnection.State);
        lblSqlWorkstationId.Text = mySqlConnection.WorkstationId;
    
        // close the connection
        mySqlConnection.Close();
    
        // *******************
        // * OleDbConnection *
        // *******************
    
        // create the object
        OleDbConnection myOleDbConnection = new OleDbConnection("provider=sqloledb;server=(local)\\BAND;database=Books;uid=band;pwd=letmein;");
    
        // open the connection
        myOleDbConnection.Open();
    
        // set the labels on the form
        lblOleDbConnectionString.Text = myOleDbConnection.ConnectionString;
        lblOleDbConnectionTimeout.Text = Convert.ToString(myOleDbConnection.ConnectionTimeout);
        lblOleDbDatabase.Text = myOleDbConnection.Database;
        lblOleDbDataSource.Text = myOleDbConnection.DataSource;
        lblOleDbProvider.Text = myOleDbConnection.Provider;
        lblOleDbServerVersion.Text = myOleDbConnection.ServerVersion;
        lblOleDbState.Text = Convert.ToString(myOleDbConnection.State);
    
        // close the connection
        myOleDbConnection.Close();
    
        // *******************
        // * OdbcConnection *
        // *******************
    
        // create the object
        OdbcConnection myOdbcConnection = new OdbcConnection("driver={SQL Server};server=(local)\\BAND;database=Books;uid=band;pwd=letmein;");
    
        // open the connection
        myOdbcConnection.Open();
    
        // set the labels on the form
        lblOdbcConnectionString.Text = myOdbcConnection.ConnectionString;
        lblOdbcConnectionTimeout.Text = Convert.ToString(myOdbcConnection.ConnectionTimeout);
        lblOdbcDatabase.Text = myOdbcConnection.Database;
        lblOdbcDataSource.Text = myOdbcConnection.DataSource;
        lblOdbcDriver.Text = myOdbcConnection.Driver;
        lblOdbcServerVersion.Text = myOdbcConnection.ServerVersion;
        lblOdbcState.Text = Convert.ToString(myOdbcConnection.State);
    
        // close the connection
        myOdbcConnection.Close();
    }

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
    <form runat="server">
        <h1>Properties from the MSDE Connection 
        </h1>
        <hr size="1" />
        <p>
        </p>
        <h2>From SqlConnection 
        </h2>
        <table>
            <tbody>
                <tr>
                    <td>
                        ConnectionString: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlConnectionString" runat="server">ConnectionString</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        ConnectionTimeout: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlConnectionTimeout" runat="server">ConnectionTimeout</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        Database: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlDatabase" runat="server">Database</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        DataSource: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlDataSource" runat="server">DataSource</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        PacketSize: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlPacketSize" runat="server">PacketSize</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        ServerVersion: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlServerVersion" runat="server">ServerVersion</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        State: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlState" runat="server">State</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        WorkstationId: 
                    </td>
                    <td>
                        <asp:Label id="lblSqlWorkstationId" runat="server">WorkstationId</asp:Label></td>
                </tr>
            </tbody>
        </table>
        <p>
        </p>
        <h2>From OleDbConnection 
        </h2>
        <table>
            <tbody>
                <tr>
                    <td>
                        ConnectionString: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbConnectionString" runat="server">ConnectionString</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        ConnectionTimeout: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbConnectionTimeout" runat="server">ConnectionTimeout</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        Database: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbDatabase" runat="server">Database</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        DataSource: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbDataSource" runat="server">DataSource</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        Provider: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbProvider" runat="server">Provider</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        ServerVersion: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbServerVersion" runat="server">ServerVersion</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        State: 
                    </td>
                    <td>
                        <asp:Label id="lblOleDbState" runat="server">State</asp:Label></td>
                </tr>
            </tbody>
        </table>
        <p>
        </p>
        <h2>From OdbcConnection 
        </h2>
        <table>
            <tbody>
                <tr>
                    <td>
                        ConnectionString: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcConnectionString" runat="server">ConnectionString</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        ConnectionTimeout: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcConnectionTimeout" runat="server">ConnectionTimeout</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        Database: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcDatabase" runat="server">Database</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        DataSource: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcDataSource" runat="server">DataSource</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        Driver: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcDriver" runat="server">Driver</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        ServerVersion: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcServerVersion" runat="server">ServerVersion</asp:Label></td>
                </tr>
                <tr>
                    <td>
                        State: 
                    </td>
                    <td>
                        <asp:Label id="lblOdbcState" runat="server">State</asp:Label></td>
                </tr>
            </tbody>
        </table>
        <p>
        </p>
    </form>
</body>
</html>

           
       
Related examples in the same category
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.