Results 1 to 5 of 5

Thread: [RESOLVED] Custom Recordset

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [RESOLVED] Custom Recordset

    Hello guys
    I'm trying to use a recordset without a database. I'm having some problems
    I got this error


    ADODB.Fields error '800a0bb9'

    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    /rev/order_Rs/dynRecordset.asp, line 13
    this is my code
    Code:
    <%
    Dim rsCustomers
    
    set rsCustomers = Server.CreateObject("ADODB.Recordset")
        
        
     
    With rsCustomers
    
    	.ActiveConnection=Nothing
    	
    	' Set CustomerID as the primary key.
    	.Fields.Append "CustomerID", adChar, 5, adFldRowID
    	.Fields.Append "CompanyName", adChar, 40, adFldUpdatable
    	.Fields.Append "Address", adChar, 60, adFldUpdatable
    	.Fields.Append "City", adChar, 15, adFldUpdatable
    	.Fields.Append "PostalCode", adChar, 10, adFldMayBeNull
    	.Fields.Append "Country", adChar, 15, adFldUpdatable
    	.Fields.Append "Phone", adChar, 24, adFldUpdatable
    
    	' Use Keyset cursor type to allow updating records.
    	.CursorType = adOpenKeyset
    	.LockType = adLockOptimistic
    
        .Open  
       End With
    
    'Now you have a <span class="highlight">recordset</span>, let's put values in it:
    
    With rsCustomers
    
            .AddNew
    
            .Fields("CustomerID").Value="AMV"
            .Fields("CompanyName").Value="PA"
            .Fields("Phone").Value="12345678"
        
            .Update
    		response.Write .fields("Phone")
    End With
    
    
    
    set rsCustomers = nothing
    %>
    can someone give me some help here?

    Thank you

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Custom Recordset

    I'm guessing you are having a problem because you are using the constant values for the cursortype and locktype but haven't declared them somewhere. Give this a try.
    Code:
    <%
    '---- CursorType Values ---- 
    Const adOpenForwardOnly = 0 
    Const adOpenKeyset = 1 
    Const adOpenDynamic = 2 
    Const adOpenStatic = 3 
    
    '---- LockTypeEnum Values ---- 
    Const adLockReadOnly = 1 
    Const adLockPessimistic = 2 
    Const adLockOptimistic = 3 
    Const adLockBatchOptimistic = 4 
    
    Dim rsCustomers
    
    set rsCustomers = Server.CreateObject("ADODB.Recordset")
        
    With rsCustomers
    
    	.ActiveConnection=Nothing
    	
    	' Set CustomerID as the primary key.
    	.Fields.Append "CustomerID", adChar, 5, adFldRowID
    	.Fields.Append "CompanyName", adChar, 40, adFldUpdatable
    	.Fields.Append "Address", adChar, 60, adFldUpdatable
    	.Fields.Append "City", adChar, 15, adFldUpdatable
    	.Fields.Append "PostalCode", adChar, 10, adFldMayBeNull
    	.Fields.Append "Country", adChar, 15, adFldUpdatable
    	.Fields.Append "Phone", adChar, 24, adFldUpdatable
    
    	' Use Keyset cursor type to allow updating records.
    	.CursorType = adOpenKeyset
    	.LockType = adLockOptimistic
    
        .Open  
       End With
    
    'Now you have a <span class="highlight">recordset</span>, let's put values in it:
    
    With rsCustomers
            .AddNew
    
            .Fields("CustomerID").Value="AMV"
            .Fields("CompanyName").Value="PA"
            .Fields("Phone").Value="12345678"
        
            .Update
    		response.Write .fields("Phone")
    End With
    
    set rsCustomers = nothing
    %>
    
    can someone give me some help here

  3. #3

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Custom Recordset

    MarkT, I've tryied your suggestion but I still got the same error in the line 23
    Code:
    '...
    	.Fields.Append "CustomerID", adChar, 5, adFldRowID
    Any sugestions, please...
    Thank you

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Custom Recordset

    Again you are still using enum constants without declaring them. Place this at the top of your code and it should run. Of course you can pick through the list an only keep the ones you are using.

    Code:
    '---- CursorType Values ---- 
    Const adOpenForwardOnly = 0 
    Const adOpenKeyset = 1 
    Const adOpenDynamic = 2 
    Const adOpenStatic = 3 
    
    '---- LockTypeEnum Values ---- 
    Const adLockReadOnly = 1 
    Const adLockPessimistic = 2 
    Const adLockOptimistic = 3 
    Const adLockBatchOptimistic = 4 
    
    '---- DataTypeEnum Values ---- 
    Const adEmpty = 0 
    Const adTinyInt = 16 
    Const adSmallInt = 2 
    Const adInteger = 3 
    Const adBigInt = 20 
    Const adUnsignedTinyInt = 17 
    Const adUnsignedSmallInt = 18 
    Const adUnsignedInt = 19 
    Const adUnsignedBigInt = 21 
    Const adSingle = 4 
    Const adDouble = 5 
    Const adCurrency = 6 
    Const adDecimal = 14 
    Const adNumeric = 131 
    Const adBoolean = 11 
    Const adError = 10 
    Const adUserDefined = 132 
    Const adVariant = 12 
    Const adIDispatch = 9 
    Const adIUnknown = 13 
    Const adGUID = 72 
    Const adDate = 7 
    Const adDBDate = 133 
    Const adDBTime = 134 
    Const adDBTimeStamp = 135 
    Const adBSTR = 8 
    Const adChar = 129 
    Const adVarChar = 200 
    Const adLongVarChar = 201 
    Const adWChar = 130 
    Const adVarWChar = 202 
    Const adLongVarWChar = 203 
    Const adBinary = 128 
    Const adVarBinary = 204 
    Const adLongVarBinary = 205
    
    '---- FieldAttributeEnum Values ---- 
    Const adFldMayDefer = &H00000002 
    Const adFldUpdatable = &H00000004 
    Const adFldUnknownUpdatable = &H00000008 
    Const adFldFixed = &H00000010 
    Const adFldIsNullable = &H00000020 
    Const adFldMayBeNull = &H00000040 
    Const adFldLong = &H00000080 
    Const adFldRowID = &H00000100 
    Const adFldRowVersion = &H00000200 
    Const adFldCacheDeferred = &H00001000

  5. #5

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Custom Recordset

    Sorry, I misunderstood. shame on me

    Ok, now it is resolved!
    Thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width