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 :

Pb de récupération d'un champ "ntext" sur une base


Sujet :

ASP

  1. #1
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut Pb de récupération d'un champ "ntext" sur une base
    Salut,

    J'ai le champ d'une tabl de ma base qui est un "ntext".
    Je ne parvient pas à remonter sont contenu qd j'utilise un objet "command". Ceci ne marche pas!
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    cm.commandtext = "SELECT Ct_ID, Ct_Journal, Ct_Comment, Ct_Name, Ct_SAPCode FROM Contract WHERE Ct_ID = " & ID & ";"
    Set rs = cm.execute
    Par contre, qd j'utilise un recordset ca marche:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    set rs = server.CreateObject("adodb.recordset")
    rs.open "SELECT Ct_ID, Ct_Journal, Ct_Name, Ct_SAPCode FROM Contract WHERE Ct_ID = " & ID & ";", strprovider,1,1
    Qqn saurait-il pourquoi?

    Merci d'avance.

  2. #2
    Membre actif Avatar de Cpas2latarte
    Inscrit en
    Janvier 2006
    Messages
    237
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 237
    Points : 255
    Points
    255
    Par défaut
    Est ce normal que les 2 requêtes aient des projections différentes?

    Sinon qu'elle est le champ nTexte

  3. #3
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Citation Envoyé par Cpas2latarte
    des projections différentes?
    Que veux-tu dire?
    Citation Envoyé par Cpas2latarte
    Sinon qu'elle est le champ nText
    Variable-length Unicode data with a maximum length of 2^30 - 1 (1,073,741,823) characters.
    Merci
    A+

  4. #4
    Membre actif Avatar de Cpas2latarte
    Inscrit en
    Janvier 2006
    Messages
    237
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 237
    Points : 255
    Points
    255
    Par défaut
    ce qu'on appel la "projection" c'est simplement l'ensemble des champs renvoyé par une requête
    si je fait
    Select a, b from truc
    ma projection est constituée des champs a et b

    Dans la requête
    "SELECT Ct_ID, Ct_Journal, Ct_Comment, Ct_Name, Ct_SAPCode FROM Contract WHERE Ct_ID = " & ID & ";"
    la projection contient le champ "Ct_Comment"

    Ce champ est abscent dans la projection de la second requête :

    "SELECT Ct_ID, Ct_Journal, Ct_Name, Ct_SAPCode FROM Contract WHERE Ct_ID = " & ID & ";", strprovider,1,1

    Est ce Normal ?

    Ne serait ce pas le champs "Ct_Comment" qui serait mal orthographié?
    Ceci expliquerai que la seconde requête fonctionne, mais pas la 1ere

    Quand à ma question, je voulais juste savoir qu'elle est le champs qui est du type nTexte, et non pas qu'est ce qu'est le type ntext ;)

    Est ce le champ "Ct_Comment" qui est du type nTexte?

  5. #5
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Autant pour moi
    C'est une erreur de frappe. Dans tous les cas le résultat est le mm.
    Le champ ntext est "Ct_Journal".
    Toutefois, je viens de m'appercevoir que le pb ne viendrait pas de l'objet (command ou recordset) mais du curseur.
    Dans le cas de la commande, il est en adOpenForwardOnly. Dans le cas du recordset il est en adOpenKeyset. Qd je met le curseur du recordset en adOpenForwardOnly (valeur "0") je recontre le mm pb qu'avec la commande.
    Pourtant, c'est tout de mm bizarre. Pourquoi ne puis-je pas récupérer mon champ?
    A+

  6. #6
    Membre actif Avatar de Cpas2latarte
    Inscrit en
    Janvier 2006
    Messages
    237
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 237
    Points : 255
    Points
    255
    Par défaut
    Et si à la place du AdForwardOnly tu utilise un AdReadOnly avec un curseur AdUseClient ça donne quoi ?

  7. #7
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Je ne sais pas trop pourquoi avec "l'ADODB.Command" ça marche pas. Toujours est-il qu'en modifiant les paramètres du recordset, j'arrive à récupérer mon champ et j'obtiens un excellent temps de réponse.Après qqs test la meilleur combinaison en terme de temps est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    rs.CursorLocation = 3 ' adUseClient
    rs.CursorType = 0 ' adOpenForwardOnly
    rs.LockType = 1 ' adLockReadOnly
    Testé sur plus de 400 000 enregistrements.
    Voici le code qui m'a permis de faire les tests:
    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
     
    on error resume next
    response.Write("<table border = '1'>" + Chr(13) + Chr(10))
    response.Write("<tr><td colspan='3'>Demandé</td><td colspan=3>Obtenu</td></tr>" + Chr(13) + Chr(10))
    response.Write("<td>Location</td><td>Type</td><td>Lock</td><td>Location</td><td>Type</td><td>Lock</td><td>Count</td><td>Time</td>" + Chr(13) + Chr(10))
    dim t
    for i = 1  to 3
    	Set rs = server.CreateObject("ADODB.Recordset")
    	rs.CursorLocation = i
    	for j = 0 to 3
    		rs.CursorType = j
    		for k = -1 to 4
    			rs.locktype = k
    			response.Write("<tr>" + Chr(13) + Chr(10))
    			response.Write("<td>" & i & "</td><td>" & j & "</td><td>" & k & "</td>" + Chr(13) + Chr(10))
    			t = cdbl(now())
    			rs.open "SELECT MonChamp FROM MaTable", strProvider
    				response.Write("<td>" & rs.CursorLocation & "</td><td>" & rs.CursorType & "</td><td>" & rs.locktype & "</td>" + Chr(13) + Chr(10))
    				IF err.number <> 0 Then
    					response.Write("<td>" & rs.recordcount & "</td>" + Chr(13) + Chr(10))
    				else
    					response.Write("<td>XXX</td>" + Chr(13) + Chr(10))
    				end if
    			rs.close
    			t = cdbl(now()) - t
    			response.Write("<td>" & t & " s</td>")
    			response.Write("</tr>" + Chr(13) + Chr(10))
    			response.Flush()
    		next
    	Next		
    	Set rs = nothing
    next
    response.Write("</table><br>" + Chr(13) + Chr(10))
    Et un petit résumé des curseurs
    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
    <table border="1" cellpadding="2">
    <tr><td colspan="3">Cursor Location</td></tr>
    <tr>
    <td><b>Constant</b></td>
    <td><b>Value</b></td>
    <td><b>Description</b></td>
    </tr><tr>
    <td><b>adUseClient</b></td>
    <td>3</td>
    <td>Use client-side cursor supplied by the local cursor library</td>
    </tr><tr>
    <td><b>adUseClientBatch</b></td>
    <td>3</td>
    <td>Obsolete, same as <b>adUseClient</b></td>
    </tr><tr>
    <td><b>adUseNone</b></td>
    <td>1</td>
    <td>Obsolete, no cursor service</td>
    </tr><tr>
    <td><b>adUseServer</b></td>
    <td>2</td>
    <td>Default, use the cursor supplied by provider or database</td>
    </tr>
    </table><br>
     
    <table border="1" cellpadding="2">
    <tr><td colspan="3">Cursor Type</td></tr>
    <tr>
    <td><b>Constant</b></td>
    <td><b>Value</b></td>
    <td><b>Description</b></td>
    </tr><tr>
    <td><b>adOpenDynamic</b></td>
    <td>2</td>
    <td>A dynamic cursor with both forward and backward scrolling where additions, deletions, 
    insertions, and updates made by other users are visible</td>
    </tr><tr>
    <td><b>adOpenForwardOnly</b></td>
    <td>0</td>
    <td>Default, a forward scrolling only, static cursor where changes made by other 
    users are not visible</td>
    </tr><tr>
    <td><b>adOpenKeyset</b></td>
    <td>1</td>
    <td>A keyset cursor allows you to see dynamic changes to a specific group of records 
    but you cannot see new records added by other users</td>
    </tr><tr>
    <td><b>adOpenStatic</b></td>
    <td>3</td>
    <td>A static cursor allowing forward and backward scrolling of a fixed, unchangeable 
    set of records</td>
    </tr><tr>
    <td><b>adOpenUnspecified</b></td>
    <td>-1</td>
    <td>Cursor type not specified</td>
    </tr>
    </table><br>
     
    <table border="1" cellpadding="2">
    <tr><td colspan="3">Lock Type</td></tr>
    <tr>
    <td><b>Constant</b></td>
    <td><b>Value</b></td>
    <td><b>Description</b></td>
    </tr><tr>
    <td><b>adLockBatchOptimistic</b></td>
    <td>4</td>
    <td>Multiple users can modify the data and the changes are cached until 
    <b>BatchUpdate</b> is called</td>
    </tr><tr>
    <td><b>adLockOptimistic</b></td>
    <td>3</td>
    <td>Multiple users can modify the data which is not locked until 
    <b>Update</b> is called</td>
    </tr><tr>
    <td><b>adLockPessimistic</b></td>
    <td>2</td>
    <td>The provider locks each record before and after you edit, and
    prevents other users from modifying the data</td>
    </tr><tr>
    <td><b>adLockReadOnly</b></td>
    <td>1</td>
    <td>Read-only data</td>
    </tr><tr>
    <td><b>adLockUnspecified</b></td>
    <td>-1</td>
    <td>Lock type unknown</td>
    </tr>
    </table><br>
    A+

Discussions similaires

  1. Réponses: 6
    Dernier message: 16/06/2006, 14h20
  2. Réponses: 5
    Dernier message: 10/05/2006, 15h47
  3. Champs de type XML dans une base de données
    Par Flocodoupoil dans le forum Décisions SGBD
    Réponses: 3
    Dernier message: 07/07/2004, 18h57

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