AccessDataSource.ConnectionString Propriété

Définition

Obtient la chaîne de connexion utilisée pour la connexion à la base de données Microsoft Access.

public:
 virtual property System::String ^ ConnectionString { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
public override string ConnectionString { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.ConnectionString : string with get, set
Public Overrides Property ConnectionString As String

Valeur de propriété

String

Chaîne de connexion OLE DB utilisée par le contrôle AccessDataSource pour se connecter à une base de données Access par le biais du fournisseur de données .NET System.Data.OleDb.

Attributs

Exceptions

Une tentative de définition de la propriété ConnectionString a été effectuée.

Exemples

L’exemple de code suivant montre comment afficher la ConnectionString propriété du AccessDataSource contrôle dans une page web ASP.NET.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private void Page_Load(Object sender, EventArgs e) {
  Label1.Text = AccessDataSource1.ConnectionString;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:AccessDataSource
        id="AccessDataSource1"
        runat="server"
        DataFile="Northwind.mdb">
      </asp:AccessDataSource>

      <asp:Label
        id="Label1"
        runat="server">
      </asp:Label>

    </form>
  </body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

  Label1.Text = AccessDataSource1.ConnectionString

End Sub 'Page_Load
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:AccessDataSource
        id="AccessDataSource1"
        runat="server"
        DataFile="Northwind.mdb">
      </asp:AccessDataSource>

      <asp:Label
        id="Label1"
        runat="server">
      </asp:Label>

    </form>
  </body>
</html>

Remarques

Le AccessDataSource contrôle ne peut être utilisé qu’avec le System.Data.OleDb fournisseur de données .NET et la chaîne de connexion utilisée AccessDataSource est spécifique à ce fournisseur. Par conséquent, le AccessDataSource contrôle expose les paramètres de chaîne de connexion, tels que la DataFile propriété, en tant que propriété et construit une chaîne de connexion au moment de l’exécution à l’aide des valeurs de la ConnectionString propriété, si elle est définie.

S’applique à

Voir aussi