Bonjour à tous,

Mon code est le suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
<%@ Page Language="C#" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<%@ import Namespace="System.Reflection" %>
<%@ import Namespace="System.Collections" %>
<%@ import Namespace="LibrairiesWeb" %>
 
<%@ import Namespace="Microsoft.Data.Odbc" %>
 
<script runat="server">
 
    private OdbcConnection mConnexion;
 
    private void OpenDatabase()
    {
        try
        {
            string nomBase = "CertificatsCadeaux";
            string m_connStr = "DSN=" + nomBase + ";";
 
            mConnexion = new OdbcConnection(m_connStr);
            mConnexion.Open();
        }
        catch(OdbcException e)
        {
            throw new Exception(e.Message + "****" + e.StackTrace, e);
        }
    }
 
    private void CloseDatabase()
    {
        mConnexion.Close();
        mConnexion.Dispose();
        mConnexion = null;
    }
 
 
    public ArrayList ObtenirListeCategories()
    {
        ArrayList listeCat = new ArrayList();
 
        try
        {
            OpenDatabase();
 
            string requete = "SELECT nom FROM Categories";
 
            OdbcCommand commande = new OdbcCommand(requete, mConnexion);
 
            // Exécution
            OdbcDataReader rslt = commande.ExecuteReader();
 
            while(rslt.Read())
            {
                  listeCat.Add(rslt.GetString(0));
            }
        }
           catch(Exception exc)
        {
               throw new Exception(exc.Message, exc);
            //MessageBox.Show(exc.Message);
        }
        finally
        {
               CloseDatabase();
        }
 
        return listeCat;
    }
 
    private void Charger(Object Sender, EventArgs E)
    {
        ArrayList listeCat = null;
 
        try
        {
            listeCat = ObtenirListeCategories();
        }
        catch(Exception exc)
        {
            Label1.Text = exc.Message + "\n" + exc.StackTrace;
        }
        //return listeCat;
    }
</script>
Mais la connexion ne se fait pas
Erreur : Source de données introuvable ou nom de pilote non spécifié

Est-ce que cela peut venir du web.config

J'ai pas vraiment d'idées

Merci