IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

exécuter une requete sur mysql


Sujet :

ASP.NET

  1. #1
    Membre confirmé
    Inscrit en
    Novembre 2005
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Novembre 2005
    Messages : 188
    Par défaut exécuter une requete sur mysql
    Salut,

    je suis dans un page (normalement) écrite en C#. Si c'est pas le cas vous pouvez me le dire...

    j'ai essayé de rajouter une requete sur mysql en suivant le tuto http://dotnet.developpez.com/faq/asp...=ado_connexion mais j'ai l'erreur suivante. Je vois pas trop quelle parenthèse il pourrait manquer...

    Compiler Error Message: CS1003: Syntax error, '(' expected
    Source Error:
    Line 120:String CRPpassword = "";
    Line 121:
    Line 122:using System;
    Line 123://using ...
    Line 124:using System.Data;
    Source File: c:\inetpub\wwwroot\Citrix\MetaFrame\auth\include\loginMainForm.inc Line: 122
    est ce que j'oublie un truc ???

    et voici le code de la page complète au cas ou...

    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
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    <%
    // loginMainForm.inc
    // Copyright (c) 2000 - 2005 Citrix Systems, Inc. All Rights Reserved.
    // Web Interface (Build 45083)
    %>
    <tr>
      <td>
        <table border='0' cellspacing='3' cellpadding='0'>
          <tr>
            <td>
              <table border="0" cellspacing='0' cellpadding='3'>
    <%
    if (viewControl.getShowLoginTypeOptions()) {
    %>
                <tr>
                  <td>
                    <table border="0" cellspacing="0" cellpadding="2">
                      <tr align='left' valign='top'>
                        <td nowrap>
                          <label id='lblLoginType' class='xsNorm' for='<%=ID_LOGIN_TYPE%>'
                              title="<%=getString("TipLoginType", currentLocale)%>"
                          <%=viewControl.getAllUIDisabledStr()%>>
                          <%=getString("LoginType", currentLocale)%>
                          </label>
                        </td>
                     </tr>
                     <tr>
                       <td colspan='2' valign='top'>
                         <select name='<%=ID_LOGIN_TYPE%>' id='<%=ID_LOGIN_TYPE%>' <%=viewControl.getAllUIDisabledStr()%>
                              class='loginEntries' size='1' onchange='onChangeLoginType(this.form)'>
    <%
        if( viewControl.allowedLogonModes().contains( AuthMethod.ANONYMOUS ) ) {
    %>
                           <option value='<%=AuthMethod.ANONYMOUS%>' <%=viewControl.getAnonymousSelectedStr()%>>
                             <%=getString("AnonymousUser", currentLocale)%>
                           </option>
    <%
        }
    %>
    <%
        if( viewControl.allowedLogonModes().contains( AuthMethod.CERTIFICATE_SINGLE_SIGN_ON ) ) {
    %>
                           <option value='<%=AuthMethod.CERTIFICATE_SINGLE_SIGN_ON%>'  <%=viewControl.getCertificateSSONSelectedStr()%>>
                             <%=getString("CertificateSSONUser", currentLocale)%>
                           </option>
    <%
        }
    %>
    <%
        if( viewControl.allowedLogonModes().contains( AuthMethod.CERTIFICATE ) ) {
    %>
                           <option value='<%=AuthMethod.CERTIFICATE%>' <%=viewControl.getCertificateSelectedStr()%>>
                             <%=getString("CertificateUser", currentLocale)%>
                           </option>
    <%
        }
    %>
    <%
        if( viewControl.allowedLogonModes().contains( AuthMethod.SINGLE_SIGN_ON ) ) {
    %>
                           <option value='<%=AuthMethod.SINGLE_SIGN_ON%>' <%=viewControl.getSSONSelectedStr()%>>
                             <%=getString("SingleSignOnUser", currentLocale)%>
                           </option>
    <%
        }
    %>
    <%
        if( viewControl.allowedLogonModes().contains( AuthMethod.EXPLICIT ) ) {
    %>
                           <option value='<%=AuthMethod.EXPLICIT%>' <%=viewControl.getExplicitSelectedStr()%>>
                             <%=getString("ExplicitUser", currentLocale)%>
                           </option>
    <%
        }
    %>
                          </select>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
    <%
    } else {
    %>
                <input type='hidden' name='<%=ID_LOGIN_TYPE%>' value='<%=AuthMethod.EXPLICIT%>'>
    <%
    }
    %>
                <tr>
                  <td colspan='3'>
    <%
    if (viewControl.getShowLoginTypeOptions()) {
    %>
                    <fieldset>
                    <legend>
                    <label id='lblCredentials' class='xsNorm' <%=viewControl.getExplicitDisabledStr()%>>
                    <%=getString("EnterLoginCredentials", currentLocale)%>
                    </label>
                    </legend>
    <%
    }
    %>
                    <table border='0' cellspacing='0' cellpadding='1'>
                      <tr>
                        <td>
                          <table border="0" cellspacing="0" cellpadding="2">
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblUserName' class='xsNorm' for='<%=ID_USER%>'
                                    title="<%=getString("TipUserName", currentLocale)%>" 
                                <%=viewControl.getExplicitDisabledStr()%>>
                                <%=getString("UserName", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
    <%
    String CRPuser = "";
    String CRPpassword = "";
     
    using System;
    //using ... 
    using System.Data; 
    using System.Data.Odbc; 
     
    //Chaine de connexion pour MyODBC 3.51 
    string MyConstring="DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=crpbioweb;" + "DATABASE=testSSOcitrix;" + "UID=root;" + "PASSWORD=;"; 
     
    OdbcConnection con = new OdbcConnection(MyConstring); 
     
    try 
    { 
       con.Open(); 
       OdbcCommand MyCommand = new OdbcCommand(); 
       MyCommand.Connection = con; 
     
       MyCommand.CommandText = "SELECT password FROM user"; 
       OdbcDataReader MyDataReader; 
       MyDataReader = MyCommand.ExecuteReader(); 
     
       while (MyDataReader.Read()) 
         { 
            Response.Write("Data:" + MyDataReader.Getstring(1));
         } 
       con.Close(); 
       } 
    catch (Exception ex) 
    { 
        Response.Write("<body><script>alert(\" "+  ex.Message + "\");</script></body>");
    }
     
    %>
     
                                <input type='text' name='<%=ID_USER%>' id='<%=ID_USER%>'
                                    class='loginEntries'
    								value='<%=CRPuser%>'
                                    maxlength='<%=LOGIN_ENTRY_MAX_LENGTH%>' <%=viewControl.getExplicitDisabledStr()%>
    <%
    if (viewControl.getUserName() != null) {
    %>
                                    value='<%=Utilities.htmlEncode(viewControl.getUserName())%>'
    <%
    }
    %>
                                    onkeyup='onUsernameTextEntry(this.form)'
                                    onChange='onUsernameTextEntry(this.form)'
                                >
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                      <tr>
                        <td>
                          <table border="0" cellspacing="0" cellpadding="2">
    <%
    if (viewControl.getShowPassword()) {
    %>
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblPasswd' class='xsNorm' for='<%=ID_PASSWORD%>'
                                    title="<%=getString("TipPassword", currentLocale)%>"
                                <%=viewControl.getExplicitDisabledStr()%>>
                                <%=getString("Password", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
                                <input type='password' name='<%=ID_PASSWORD%>' id='<%=ID_PASSWORD%>' value='<%=CRPpassword%>'
                                    class='loginEntries'
                                    maxlength='<%=LOGIN_ENTRY_MAX_LENGTH%>' <%=viewControl.getExplicitDisabledStr()%>>
                              </td>
                            </tr>
    <%
    } else if (viewControl.getShowPasscode()) { //if passcode is visible, but password is not, then replace the password field with the passcode field
    %>
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblPasscode' for='<%=ID_PASSCODE%>' class='xsNorm'
                                    title="<%=getString("TipPasscode", currentLocale)%>"
                                <%=viewControl.getExplicitDisabledStr()%>>
                                <%=getString("Passcode", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
                                <input type='password' name='<%=ID_PASSCODE%>' id='<%=ID_PASSCODE%>'
                                    class='loginEntries' maxlength='<%=LOGIN_ENTRY_MAX_LENGTH%>' <%=viewControl.getExplicitDisabledStr()%>>
                              </td>
                           </tr>
    <%
    }
    %>
                          </table>
                        </td>
                      </tr>
    <%
    if (viewControl.getShowDomain()) {
    %>
                      <tr>
                        <td>
                          <table border="0" cellspacing="0" cellpadding="2">
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblDomain' class='xsNorm' for='<%=ID_DOMAIN%>'
                                    title="<%=getString("TipDomain", currentLocale)%>"
                                <%=viewControl.getDomainDisabledStr()%>>
                                <%=getString("Domain", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
    <%
        if (viewControl.getRestrictDomains() || viewControl.getNumLoginDomains() > 0) {
    %>
                                <select class='loginEntries' size='1'
                                      name='<%=ID_DOMAIN%>' id='<%=ID_DOMAIN%>'
                                  <%=viewControl.getDomainDisabledStr()%>>
    <%
            for (int i=0; i < viewControl.getNumLoginDomains(); i++) {
    %>
                                  <option value='<%=Utilities.htmlEncode(viewControl.getLoginDomains()[i])%>'>
                                    <%=Utilities.htmlEncode(viewControl.getLoginDomains()[i])%>
                                  </option>
    <%
            }
    %>
                                </select>
    <%
        } else {
    %>
                                <input type='text' class='loginEntries'
                                    name='<%=ID_DOMAIN%>' id='<%=ID_DOMAIN%>'
                                    MAXLENGTH='<%=LOGIN_ENTRY_MAX_LENGTH%>'
                                <%=viewControl.getDomainDisabledStr()%>>
    <%
        }
    %>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
    <%
    }
     
    if (viewControl.getNDSEnabled()) {
        if (viewControl.getNumNDSContexts() > 0 || viewControl.getShowFindContext()) {
    %>
                      <tr>
                        <td>
                          <table border="0" cellspacing="0" cellpadding="2">
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblContext' class='xsNorm'
                                    for='<%=ID_CONTEXT%>'
                                    title="<%=getString("TipContext", currentLocale)%>">
                                <%=getString("Context", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
                                <select name='<%=ID_CONTEXT%>' id='<%=ID_CONTEXT%>'
                                      size='1' class='loginEntries'>
    <%
            // Find context is always at the top of the list if it is present
            // Only selected if there are no found contexts being shown
            if (viewControl.getShowFindContext()) {
    %>
                                  <option <%=(viewControl.getNumNDSContexts() > 0) ? "" : "selected"%>>
                                    <%=getString("lookupContextString", currentLocale)%>
                                  </option>
    <%
            }
            if (viewControl.getNumNDSContexts() > 0) {
                for (int j=0; j < viewControl.getNumNDSContexts(); j++) {
    %>
                                  <option <%=(j == 0) ? "selected" : ""%>
                                        value='<%=Utilities.htmlEncode(viewControl.getNDSContexts()[j])%>'>
                                    <%=Utilities.htmlEncode(viewControl.getNDSContexts()[j])%>
                                  </option>
    <%
                }
            }
    %>
                                </select>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
    <%
        }
    %>
                      <tr>
                        <td>
                          <table border="0" cellspacing="0" cellpadding="2">
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblTree' class='xsNorm' for='<%=ID_TREE%>'
                                    title="<%=getString("TipTree", currentLocale)%>">
                                <%=getString("Tree", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
                                <input type='text' readonly name='<%=ID_TREE%>' id='<%=ID_TREE%>'
                                    class='loginTreeEntry' value='<%=Utilities.htmlEncode(viewControl.getNDSTree())%>'>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
    <%
    }
     
    if (viewControl.getShowPasscode() && viewControl.getShowPassword() ) { //only display the passcode field here if the password field is displayed above
    %>
                      <tr>
                        <td>
                          <table border="0" cellspacing="0" cellpadding="3">
                            <tr>
                              <td align='left' valign='top' nowrap>
                                <label id='lblPasscode' for='<%=ID_PASSCODE%>' class='xsNorm'
                                    title="<%=getString("TipPasscode", currentLocale)%>"
                                <%=viewControl.getExplicitDisabledStr()%>>
                                <%=getString("Passcode", currentLocale)%>
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td valign='top'>
                                <input type='password' name='<%=ID_PASSCODE%>' id='<%=ID_PASSCODE%>'
                                    class='loginEntries' maxlength='<%=LOGIN_ENTRY_MAX_LENGTH%>' <%=viewControl.getExplicitDisabledStr()%>>
                              </td>
                           </tr>
                          </table>
                        </td>
                      </tr>
    <%
    }
    %>
                    </table>
    <%
    if (viewControl.getShowLoginTypeOptions()) {
    %>
                    </fieldset>
    <%
    }
    %>
                  </td>
                </tr>
                <tr name="<%=ID_OPENLINK_ADV_OPTIONS%>" id="<%=ID_OPENLINK_ADV_OPTIONS%>" <%=viewControl.getAdvancedOptionsOpenLinkDisplayStr()%>>
                  <td align="right"><a href="#<%=ID_ADV_OPTIONS_ANCHOR%>" class="appLinksSmall" onClick="openAdvOptions(this.form)"><%=getString("AdvancedOptionsOpen", currentLocale)%></a></td>
                </tr>
    <%
    if (! viewControl.getShowAdvancedOptionsPermanently()) {
    %>
                <tr name="<%=ID_CLOSELINK_ADV_OPTIONS%>" id="<%=ID_CLOSELINK_ADV_OPTIONS%>" <%=viewControl.getAdvancedOptionsCloseLinkDisplayStr()%>>
                  <td align="right"><a href="#" class="appLinksSmall" onClick="closeAdvOptions(this.form)"><%=getString("AdvancedOptionsClose", currentLocale)%></a></td>
                </tr>
    <%
    }
    %>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>

    merci

  2. #2
    Membre chevronné
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2004
    Messages
    417
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2004
    Messages : 417
    Par défaut
    la comme ca je peux pas trop te dire.

    Mais franchement on code pas comme ca enfin pour mon cas.
    dans la page aspx on de doit pas mettre de code.
    ex tous tes if tu peux les remplace pars un panel ou un placeholder.
    Puis dans l'evenment OnLoad en code behind, ici tu fais tes if et tu joue sur l'attribut visible des panels et/ou des placeholder.

    sinon j'avais jamais vu d'utiliser des using en pleins millieux du code. Ca peut peut etre marcher mais franchement faut pas.

    Attention le prend pas mal, j'essai pas de te rabaisser.

    Je pense que tu devrais transformer ton code pour que tes instructions C# soit en code behind.
    Ca sera deja plus clair.
    Peut etre que je me trompe aussi
    Bon courage

  3. #3
    Membre confirmé
    Inscrit en
    Novembre 2005
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Novembre 2005
    Messages : 188
    Par défaut
    le code c'est pas moi qui l'ait écrit, c'est citrix !!!

    j'essaye désespérement de rajouter un toute bete requete mysql au milieu de la page pour implémenter un single sign on maison. je veux toucher à un minumum de choses à leurs codes. en plus jusqu'a ce matin, je connaissais pas du tout .net.

    est ce que tu n'aurais pas un bout de code avec un select qui marche?

  4. #4
    Membre chevronné
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2004
    Messages
    417
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2004
    Messages : 417
    Par défaut
    voila le code de la msdn si ca peut t'aider

    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
    string query = "SELECT [Order ID], [Customer] FROM Orders";
    SqlCeConnection conn = new SqlCeConnection(connString);
    SqlCeCommand cmd = new SqlCeCommand(query, conn);
     
    conn.Open();
    SqlCeDataReader rdr = cmd.ExecuteReader();
     
    try
    {
        // Iterate through the results
        //
        while (rdr.Read())
        {
            int val1 = rdr.GetInt32(0);
            string val2 = rdr.GetString(1);
        }
    }
    finally
    {
        // Always call Close when done reading
        //
        rdr.Close();
     
        // Always call Close when done reading
        //
        conn.Close();
    }

  5. #5
    Membre confirmé
    Inscrit en
    Novembre 2005
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Novembre 2005
    Messages : 188
    Par défaut
    t'as trouvé ca ou stp?

  6. #6
    Membre chevronné
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2004
    Messages
    417
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2004
    Messages : 417
    Par défaut
    a j'avoue si msdn te dit rien c'est dommage.
    c'est la doc microsoft.
    La bible

    Mais si c'est la premiere fois que tu l'utilise tu vas trouve ca hyper fouillis

    http://msdn2.microsoft.com/fr-fr/lib...nd(VS.80).aspx

    http://msdn2.microsoft.com/fr-fr/

  7. #7
    Membre confirmé
    Inscrit en
    Novembre 2005
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Novembre 2005
    Messages : 188
    Par défaut
    merci je vais jeter un oeil.

    sur le site de microsoft, j'y vais que pour les updates d'habitude !

Discussions similaires

  1. [Admin] impossible d'exécuter une requete sur un univers
    Par sara_sihem dans le forum Administration-Migration
    Réponses: 5
    Dernier message: 30/12/2009, 14h39
  2. Exécution d'une requete sur un DataSet
    Par Nico_stras dans le forum C#
    Réponses: 2
    Dernier message: 01/09/2007, 09h43
  3. créer une interface utilisateur console pour requetes sur mysql
    Par begonia dans le forum Shell et commandes GNU
    Réponses: 2
    Dernier message: 23/03/2007, 15h16
  4. [Vba-Excel] Exécuter une requete SQL sur une feuille de donnée
    Par Spacy_green dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 30/11/2006, 09h27
  5. Experts Mysql : Optimiser une requete sur codes postaux
    Par El Riiico dans le forum Requêtes
    Réponses: 6
    Dernier message: 20/01/2006, 18h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo