Bonjour,

Voici un script très simple pour tester l'état de ma connection à ma base de donnée MySQL via une page ASP.NET avec script C#.

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
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Odbc" %> <script runat="server">
 
    void Page_Load() {
 
         // initialize the connection string
         string strConnection = "Driver={MySQL ODBC 3.51
 Driver};Server=localhost;Database=sleepeeg;uid=root;pwd=";
 
         // instantiate an instance of the OdbcConnection object
         OdbcConnection objConn = new OdbcConnection(strConnection);
 
         // create an instance of the OdbcCommand object
         OdbcCommand objCommand = new OdbcCommand("SELECT * FROM
 macro", objConn);
 
         // open a database connection
         objConn.Open();
 
         // initialize the OdbcDataReader object
         OdbcDataReader objRdr = objCommand.ExecuteReader();
 
        while(objRdr.read()){
            response.write(" Hello World");
        }
         // assign the OdbcDataReader object as the source
         // for the "dgbooks" datagrid
       //dgbooks.DataSource = objRdr;
         //dgbooks.DataBind();
 
         // free up memory
         objRdr.Close();
         objConn.Close();
    }
 
</script>
<html>
<head>
<title>My Book Collection</title>
</head>
<body>
<asp:datagrid id="dgbooks" runat="server" font-size="12" font-
name="Arial" width="700" cellpadding="5" cellspacing="2">
    <headerstyle backcolor="#000000" forecolor="#FFFFFF"/>
</asp:datagrid> </body> </html>
Tout cela fonctionne très bien (si on ne tiens pas compte du rouge)... Par contre, ce qui m'intéresse, c'est le parcours de la réponse de ma requête SQL que j'aimerai renvoyer par la méthode response.write() (car script destiné à répondre à des requètes XmlHttpRequest.

Voila l'erreur que j'obtient avec ce script... Très étrange étant donné que théoriquement, le framework.NET 1.1 est correctement installé sur mon PC

CS0117: 'System.Data.Odbc.OdbcDataReader' ne contient pas de définition pour 'read'
Quelqu'un a-t'il une idée ?
Une autre méthode pour parcourir les éléments de l'objet ObjRdr ?

Merci beaucoup