Use OdbcConnection : ODBC « ADO.net Database « ASP.Net






Use OdbcConnection


<%@ Page Language="C#" %>
<%@ Import Namespace="Microsoft.Data.Odbc" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e) 
{
    String connectString = "DSN=myDSN;Uid=user;Pwd=pass";

    OdbcConnection myConn = null;

    try
    {      
      myConn = new OdbcConnection( connectString );    
      myConn.Open();
        
      lblConnectInfo.Text = "Connection successful!";
    }
    catch
    {
      lblConnectInfo.Text = "Connection failed!";
    }
    finally
    {
      if (myConn != null)
        myConn.Close();
    }        
}
</script>
<html>
  <head>
    <title></title>
  </head>
  <body>
    <form id="form1" method="post" runat="server">
      Open an ODBC connection.
      <asp:Label id="lblConnectInfo" runat="server"></asp:Label>
    </form>
  </body>
</html>

 








Related examples in the same category