rs.save in VB crach with code 2147286781 (80030103)

Answered rs.save in VB crach with code 2147286781 (80030103)

  • Wednesday, July 27, 2011 11:43 AM
     
     

    I have a vb script in access 2007 and there I read some text documents and save them as record in the database. This is on a machine with windows 7. When I do this without sp1 for windows 7 it all works. When i install sp1 on windows 7 then I get the error massage cannot save with the code 2147286781 (80030103). In the VB code I use rs.save. I put a example of the code below. Here i created a new DB and want to save 1 record. I got the same error back.

    There is a old artikel (http://support.microsoft.com/kb/818518) with the same problem, but there is no new MDAC for windows 7.

    Is there a solution for the problem I have?

     

    Private Sub KnopVerwerk_Click()
    Dim cnn As Connection
    Set cnn = CurrentProject.Connection

    Dim RS As New ADODB.Recordset
    RS.Open "Journaal", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect

    'verwerken in journaal
    RS.AddNew
    RS!diernummer = "A"
    RS!actie = "B"
    RS!gebruiker = "C"
    RS!bestherk = "D"
    RS!DatumTijd = "123"
    RS.Save
    RS.Close
        
    End Sub

    • Moved by Nick Wan Monday, August 01, 2011 2:04 AM vba (From:Office 2010 Setup and Deployment)
    •  

All Replies

  • Monday, August 01, 2011 4:19 AM
    Moderator
     
     

    Hi Meijerpcbeheer,

    I can't reproduce the problem on my side. Your code works well on my side and my enviroment is Windows 7 + Access 2007 and sp1. What is the type of the filed DatumTijd ? Is it text field?

    Try to compact & repair your Access application to see whether such error occurs.

    Hope this helps and wish you a nice day.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Monday, August 01, 2011 1:56 PM
     
     

    The field DatumTijd is a DateTime field. The problem doesn't occur after changing the fields, but after the rs.save.
    You wrote : "my enviroment is Windows 7 + Access 2007 and sp1".  In MY case the sp1 belongs to windows 7. Is that what you mean?

    kind regard

    Paul Meijer

     


    paul Meijer
  • Monday, August 01, 2011 3:45 PM
     
     Answered Has Code

    Hi Paul,

     

    If "DatumTijd" is a DateTime Field, and you try to write a Numeric/ String value will problably give a "Type Missmatch" error.

     

     

    The following changes I made in your code:
    
    Dim cnn As ADODB.Connection
    Set cnn = CurrentProject.Connection
    
    Dim RS As ADODB.Recordset
    Set RS = New ADODB.Recordset
    
    
    RS.Open "SELECT * FROM Journaal", cnn, adOpenStatic, adLockOptimistic
    
    
    'verwerken in journaal
    RS.AddNew
     RS!diernummer = "A"
     RS!actie = "B"
     RS!gebruiker = "C"
     RS!bestherk = "D"
    
     'use valid date value, use Date as test
     RS!DatumTijd = Date
    
    'Use update to save the record
    
    RS.Update
    
    'closing the recordset
    
    RS.Close
    
    
    'release objects
    Set cnn = Nothing
    Set RS = Nothing

     

     

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"


    • Proposed As Answer by danishani Saturday, August 06, 2011 2:45 PM
    • Marked As Answer by Bruce SongModerator Tuesday, August 09, 2011 8:59 AM
    •  
  • Sunday, August 07, 2011 3:21 PM
     
     Answered

    Thanks for the help. I change rs.save to rs.update and this is the solution for the problem.

     


    paul Meijer
    • Marked As Answer by meijerpcbeheer Sunday, August 07, 2011 3:21 PM
    •