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 Discussion :

ASP SQL Server Formulaire


Sujet :

ASP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2009
    Messages : 33
    Par défaut ASP SQL Server Formulaire
    Bonjour,

    Je travaille actuellement sous ASP avec une base SQL SERVER.

    Quand je crée un formulaire d'actualisation celui-ci affiche toutes les valeurs stockées dans la base SQL au niveau du formulaire sauf Un...( pourtant la valeur dans la table n'est pas vide nvar)!

    Je rempli le champ dans le formulaire(champ vide) et celui-ci est bien enrergistré dans la base mais n'apparait tjs pas dans le formulaire !

    Qqun aurait il une idée?

    D'avance merci.

  2. #2
    Expert confirmé

    Avatar de Philippe Vialatte
    Homme Profil pro
    Architecte technique
    Inscrit en
    Juillet 2004
    Messages
    3 029
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juillet 2004
    Messages : 3 029
    Par défaut
    Salut,

    Je travaille actuellement sous ASP avec une base SQL SERVER.
    ASP, ou ASP.Net ?

    Je rempli le champ dans le formulaire(champ vide) et celui-ci est bien enrergistré dans la base mais n'apparait tjs pas dans le formulaire !
    Je pense que ton code doit avoir un souci, mais si tu ne nous en dis pas plus, ca va etre difficile de voir lequel

    Mon Blog

    The Cake is still a lie !!!



    Vous voulez contribuer à la rubrique .NET ? Contactez-moi par MP.
    Vous voulez rédiger des articles pour la rubrique .NET ? Voici la procédure à suivre.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2009
    Messages : 33
    Par défaut
    Bonjour,

    Je suis sous ASP liaison avec base SQL SERVER.

    Le code de la page ci-dessous

    Je me demandais si cela ne venait pas d'élément du genre cursorlocation( euh novice..)


    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
     
    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="../../Connections/sqlfncas.asp" -->
    <%
    Dim MM_editAction
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
    End If
     
    ' boolean to abort record edit
    Dim MM_abortEdit
    MM_abortEdit = false
    %>
    <%
    ' IIf implementation
    Function MM_IIf(condition, ifTrue, ifFalse)
      If condition = "" Then
        MM_IIf = ifFalse
      Else
        MM_IIf = ifTrue
      End If
    End Function
    %>
    <%
    If (CStr(Request("MM_update")) = "form1") Then
      If (Not MM_abortEdit) Then
        ' execute the update
        Dim MM_editCmd
     
        Set MM_editCmd = Server.CreateObject ("ADODB.Command")
        MM_editCmd.ActiveConnection = MM_sqlfncas_STRING
        MM_editCmd.CommandText = "UPDATE dbo.Structures SET datemaj = ?, nomstructure = ?, crealieepassagerce = ?, datecreatestructure = ?, adressestructure = ?, codepostalstructure = ?, villestructure = ?, telstructure = ?, faxstructure = ?, courrielstructure = ?, webstructure = ?, titreresponsable = ?, nomresponsable = ?, prenomresponsable = ?, telresponsable = ?, courrielresponsable = ?, Interventionsociale = ?, interventionautres = ?, personfonctstruc = ?, quotiteetp = ?, motivationchoixtypestruct = ? WHERE idstructure = ?" 
        MM_editCmd.Prepared = true
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 135, 1, -1, MM_IIF(Request.Form("datemaj"), Request.Form("datemaj"), null)) ' adDBTimeStamp
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("nomstructure")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("crealieepassagerce"), 1, 0)) ' adDouble
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 135, 1, -1, MM_IIF(Request.Form("datecreatestructure"), Request.Form("datecreatestructure"), null)) ' adDBTimeStamp
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 203, 1, 1073741823, Request.Form("adressestructure")) ' adLongVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("codepostalstructure"), Request.Form("codepostalstructure"), null)) ' adDouble
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 50, Request.Form("villestructure")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 50, Request.Form("telstructure")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 50, Request.Form("faxstructure")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 50, Request.Form("courrielstructure")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("webstructure")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202, 1, 50, Request.Form("titreresponsable")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 202, 1, 50, Request.Form("nomresponsable")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 202, 1, 50, Request.Form("prenomresponsable")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 202, 1, 50, Request.Form("telresponsable")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param16", 202, 1, 50, Request.Form("courrielresponsable")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param17", 203, 1, 1073741823, Request.Form("Interventionsociale")) ' adLongVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param18", 203, 1, 1073741823, Request.Form("interventionautres")) ' adLongVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param19", 5, 1, -1, MM_IIF(Request.Form("personfonctstruc"), Request.Form("personfonctstruc"), null)) ' adDouble
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param20", 5, 1, -1, MM_IIF(Request.Form("quotiteetp"), Request.Form("quotiteetp"), null)) ' adDouble
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param21", 203, 1, 1073741823, Request.Form("motivationchoixtypestruct")) ' adLongVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param22", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
        MM_editCmd.Execute
        MM_editCmd.ActiveConnection.Close
     
        ' append the query string to the redirect URL
        Dim MM_editRedirectUrl
        MM_editRedirectUrl = "bureau2.asp"
        If (Request.QueryString <> "") Then
          If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
            MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
          Else
            MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
          End If
        End If
        Response.Redirect(MM_editRedirectUrl)
      End If
    End If
    %>
    <%
    Dim bureau__MMColParam
    bureau__MMColParam = "26"
    If (Session("idstructure")  <> "") Then 
      bureau__MMColParam = Session("idstructure") 
    End If
    %>
    <%
    Dim bureau
    Dim bureau_cmd
    Dim bureau_numRows
     
    Set bureau_cmd = Server.CreateObject ("ADODB.Command")
     
    bureau_cmd.ActiveConnection = MM_sqlfncas_STRING
    bureau_cmd.CommandText = "SELECT idstructure, datecreatestructure, crealieepassagerce, datemaj, nomstructure, adressestructure, codepostalstructure, villestructure, telstructure, faxstructure, courrielstructure, webstructure, titreresponsable, nomresponsable, prenomresponsable, telresponsable, courrielresponsable, Interventionsociale, interventionautres, personfonctstruc, quotiteetp, motivationchoixtypestruct FROM dbo.Structures WHERE idstructure = ?" 
     
    bureau_cmd.Prepared = true
     
     
    bureau_cmd.Parameters.Append bureau_cmd.CreateParameter("param1", 5, 1, -1, bureau__MMColParam) ' adDouble
     
    Set bureau = bureau_cmd.Execute
    bureau_numRows = 0
    %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/INTRAenquete.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Document sans titre</title>
    <!-- InstanceEndEditable -->
    <!-- InstanceBeginEditable name="head" -->
    <!-- InstanceEndEditable -->
    <style type="text/css">
    <!--
    .Style5 {color: #FFFFFF; font-weight: bold; }
    .Style5 {color: #FFFFFF; font-weight: bold; }
    -->
    </style>
    <link href="../../css/cms.css" rel="stylesheet" type="text/css" />
    </head>
     
    <body>
    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="2"><img src="../img/bandeauintra.gif" width="800" height="100" /></td>
          </tr>
          <tr>
            <td bgcolor="#003366"><span class="Style5">ENQUETE FNCAS</span></td>
            <td bgcolor="#003366"><form>
              <div align="right">
                <input type="button" class="form" onclick="history.back()" value="Retour" />
              </div>
            </form>
              <div align="right"></div></td>
          </tr>
          <tr>
            <td colspan="2"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="46" valign="top"><!-- InstanceBeginEditable name="contenu" -->
    <%=(bureau.Fields.Item("adressestructure").Value)%><%=(bureau.Fields.Item("codepostalstructure").Value)%><br />
    <%=(bureau.Fields.Item("villestructure").Value)%><br />
    <form action="<%=MM_editAction%>" method="POST" name="form1" id="form1">
      <%=(bureau.Fields.Item("adressestructure").Value)%>
      <table align="center">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Datemaj:</td>
          <td><input type="text" name="datemaj" value="<%=(bureau.Fields.Item("datemaj").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Nomstructure:</td>
          <td><input type="text" name="nomstructure" value="<%=(bureau.Fields.Item("nomstructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Crealieepassagerce:</td>
          <td><input type="checkbox" name="crealieepassagerce" value="1" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Datecreatestructure:</td>
          <td><input type="text" name="datecreatestructure" value="<%=(bureau.Fields.Item("datecreatestructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Adressestructure:</td>
          <td><input type="text" name="adressestructure" value="<%= LCase((bureau.Fields.Item("adressestructure").Value)) %>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Codepostalstructure:</td>
          <td><input type="text" name="codepostalstructure" value="<%=(bureau.Fields.Item("codepostalstructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Villestructure:</td>
          <td><input type="text" name="villestructure" value="<%=(bureau.Fields.Item("villestructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Telstructure:</td>
          <td><input type="text" name="telstructure" value="<%=(bureau.Fields.Item("telstructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Faxstructure:</td>
          <td><input type="text" name="faxstructure" value="<%=(bureau.Fields.Item("faxstructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Courrielstructure:</td>
          <td><input type="text" name="courrielstructure" value="<%=(bureau.Fields.Item("courrielstructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Webstructure:</td>
          <td><input type="text" name="webstructure" value="<%=(bureau.Fields.Item("webstructure").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Titreresponsable:</td>
          <td><select name="titreresponsable">
            <option value="Madame"  <%If (Not isNull(bureau.Fields.Item("titreresponsable").Value)) Then If ("Madame" = CStr(bureau.Fields.Item("titreresponsable").Value)) Then Response.Write("selected='selected'") : Response.Write("")%>>Madame</option>
            <option value="Monsieur"  <%If (Not isNull(bureau.Fields.Item("titreresponsable").Value)) Then If ("Monsieur" = CStr(bureau.Fields.Item("titreresponsable").Value)) Then Response.Write("selected='selected'") : Response.Write("")%>>Monsieur</option>
          </select></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Nomresponsable:</td>
          <td><input type="text" name="nomresponsable" value="<%=(bureau.Fields.Item("nomresponsable").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Prenomresponsable:</td>
          <td><input type="text" name="prenomresponsable" value="<%=(bureau.Fields.Item("prenomresponsable").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Telresponsable:</td>
          <td><input type="text" name="telresponsable" value="<%=(bureau.Fields.Item("telresponsable").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Courrielresponsable:</td>
          <td><input type="text" name="courrielresponsable" value="<%=(bureau.Fields.Item("courrielresponsable").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Interventionsociale:</td>
          <td><input type="text" name="Interventionsociale" value="<%=(bureau.Fields.Item("Interventionsociale").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Interventionautres:</td>
          <td><input type="text" name="interventionautres" value="<%=(bureau.Fields.Item("interventionautres").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Personfonctstruc:</td>
          <td><input type="text" name="personfonctstruc" value="<%=(bureau.Fields.Item("personfonctstruc").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Quotiteetp:</td>
          <td><input type="text" name="quotiteetp" value="<%=(bureau.Fields.Item("quotiteetp").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Motivationchoixtypestruct:</td>
          <td><input type="text" name="motivationchoixtypestruct" value="<%=(bureau.Fields.Item("motivationchoixtypestruct").Value)%>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td><input type="submit" value="Mettre &agrave; jour l'enregistrement" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_update" value="form1" />
      <input type="hidden" name="MM_recordId" value="<%= bureau.Fields.Item("idstructure").Value %>" />
    </form>
    <p>&nbsp;</p>
    <!-- InstanceEndEditable --><br />
                      <br />
                      <h2>&nbsp;</h2></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td bgcolor="#003366"><span class="Style5">FNCAS </span></td>
            <td bgcolor="#003366">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    <%
    bureau.Close()
    Set bureau = Nothing
    %>

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2009
    Messages : 33
    Par défaut
    Re bonjour,

    Cela fonctionne désormais j ai changé de type de champ pour les données qui n'apparaissaient pas dans le formulaire

    PASSAGE DE NVARCHAR EN NVARCHAR(255) et cela fonctionne...

    Mais bon j'aurais bien aimé avoir une explication logique !


    Merci

  5. #5
    Expert confirmé

    Avatar de Philippe Vialatte
    Homme Profil pro
    Architecte technique
    Inscrit en
    Juillet 2004
    Messages
    3 029
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juillet 2004
    Messages : 3 029
    Par défaut
    Citation Envoyé par lstephan
    Je suis sous ASP liaison avec base SQL SERVER.
    Alors, malheureusement, comme tu es sur le forum asp.Net, perso, j'ai beaucoup de mal avec ASP...

    Mais bon, perso, un champ nvarchar dont la longueur n'est pas définie, ca me fait mal alors...

    Mon Blog

    The Cake is still a lie !!!



    Vous voulez contribuer à la rubrique .NET ? Contactez-moi par MP.
    Vous voulez rédiger des articles pour la rubrique .NET ? Voici la procédure à suivre.

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2009
    Messages : 33
    Par défaut
    Désolé j ai posté un peu trop rapidement mon message.

    En fait initialement ce champ problématique était en ntext.

    Le fait de le passer en nvarchar(255) a résolu etonnament mon problème (enfin pour le novice que je suis).


    Merci en tout cas pour les conseils.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. asp sql server formulaire update
    Par lstephan dans le forum ASP
    Réponses: 2
    Dernier message: 02/11/2009, 14h05
  2. Réponses: 4
    Dernier message: 05/05/2006, 15h45
  3. ASP/ SQL Server : resultat de RS dans une cellule.
    Par joe_le_mort dans le forum ASP
    Réponses: 2
    Dernier message: 11/08/2005, 13h26
  4. Regroupement d'enregistrements en ASP/SQL Server
    Par Matlight dans le forum ASP
    Réponses: 3
    Dernier message: 02/04/2004, 13h31

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