Properties of OleDbConnection : OleDbConnection « ADO.net Database « ASP.NET Tutorial






<%@ 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) {
        OleDbConnection myOleDbConnection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="+ Server.MapPath("EmployeeDatabase.mdb;"));

        myOleDbConnection.Open();
    
        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);
    
        myOleDbConnection.Close();
    }
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <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>
    </form>
</body>
</html>








18.10.OleDbConnection
18.10.1.Properties of OleDbConnection
18.10.2.Connecting to an Access Database