Solved

Multiple-step OLE DB Operation generated errors.

Posted on 2013-11-11
8
1,130 Views
Last Modified: 2013-11-11
Getting a Run-time error: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. On 2 rows below. Not sure what the issue is? Or how to fix. But if I drag past or comment out the offending rows it works fine. Anyone have any suggestions?



Public Sub ExportToTimeTrac(ID As String, ImportDate As Date, BadgeNumber As String, _
                            FirstName As String, LastName As String, MiddleInitial As String, _
                            Supervisor As String, Status As String, EmployeeGroup As String, _
                            PeriodCycle As String, ShiftSchedule As String, Source As String, _
                            ScheduleImport As String, ScheduleType As String, Vacation As Single, _
                            Sick As Single, _
                            JCC1 As String, WR1 As String, WageType1 As String, CC1 As String, _
                            JCC2 As String, WR2 As String, WageType2 As String, CC2 As String, _
                            JCC3 As String, WR3 As String, WageType3 As String, CC3 As String, _
                            JCC4 As String, WR4 As String, WageType4 As String, CC4 As String, _
                            JCC5 As String, WR5 As String, WageType5 As String, CC5 As String, _
                            ImportSource As String, ImportStatus As String, LastUpdated As Date)
                           
    '  Procedure is used to export records to the time trac database for import.  If testing mode
    '  data will go to test database - SAMC135, else production SAMC 136
    ''''Dim wsp As Workspace
    ''''Dim con As Connection
    ''''Dim rs As Recordset
    ''''Dim fTest As Boolean
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
   
    Set con = New ADODB.Connection
    Set rs = New ADODB.Recordset
   
    '  Are we in a Test mode?
    ''''fTest = TestDatabase
   
    '  Create the ODBC Connection
    ''''Call RegisterTTDatabase(fTest)
   
    ''''Set wsp = CreateWorkspace("", "timetrac", "atks*atks", dbUseODBC)
   
    ''''If fTest = True Then
        '  Point to test
        'Set con = wsp.OpenConnection("TT", , , "ODBC;Database=TimeTracTest;UID=timetrac,PWD=atks*atks;DSN=HRISTimeTracTest")
        ''''Set con = wsp.OpenConnection("TT", , , "ODBC;Database=TimeTracTest;UID=timetrac;PWD=atks*atks;DSN=HRISTimeTracTest")
    ''''Else
        '  Point to production
        'Set con = wsp.OpenConnection("TT", , , "ODBC;Database=TimeTrac;UID=timetrac;PWD=atks*atks;DSN=HRISTimeTrac")
        ''''Set con = wsp.OpenConnection("TT", , , "ODBC;Database=TimeTrac;UID=timetrac;PWD=atks*atks;DSN=TimeTrac")
    ''''End If
   
    ''''Set rs = con.OpenRecordset("EmployeesImport", dbOpenDynaset, 0, dbPessimistic)
    con.Open _
    "Provider = sqloledb;" & _
    "Data Source=FR01APTATK01;" & _
    "Initial Catalog=TimeTrac;" & _
    "User ID=timetrac;" & _
    "Password=atks*atks;"

    rs.Open "EmployeesImport", con, adOpenDynamic, adLockOptimistic
   
    With rs
        .AddNew
            .Fields("Employee") = ID
            .Fields("ImportDate") = ImportDate
            .Fields("Badge") = BadgeNumber
            .Fields("Company") = "1"            '  Default 1 -Saint Agnes Medical Center
            .Fields("FirstName") = FirstName
            .Fields("LastName") = LastName
            .Fields("MiddleInitial") = MiddleInitial
            .Fields("Supervisor") = Supervisor
-->On this row            .Fields("Status") = Status
            .Fields("EmployeeGroup") = EmployeeGroup
            .Fields("SubGroup") = " "           '  Sub group - pass a blank
            .Fields("Class") = "A1-A1"          '  Default A1-A1  does not mean anything
            .Fields("HomeCostCenter") = CC1
            .Fields("PeriodCycle") = PeriodCycle
            .Fields("ShiftSchedule") = ShiftSchedule
            .Fields("Source") = Source
            .Fields("ScheduleImport") = ScheduleImport
            .Fields("ScheduleType") = ScheduleType
            .Fields("VacationAccrued") = Vacation
            .Fields("SickAccrued") = Sick
            .Fields("JobCode1") = JCC1
            .Fields("WorkRule1") = WR1
            .Fields("WageType1") = WageType1
            .Fields("CostCenter1") = CC1
            .Fields("JobCode2") = JCC2
            .Fields("WorkRule2") = WR2
            .Fields("WageType2") = WageType2
            .Fields("CostCenter2") = CC2
            .Fields("JobCode3") = JCC3
            .Fields("WorkRule3") = WR3
            .Fields("WageType3") = WageType3
            .Fields("CostCenter3") = CC3
            .Fields("JobCode4") = JCC4
            .Fields("WorkRule4") = WR4
            .Fields("WageType4") = WageType4
            .Fields("CostCenter4") = CC4
            .Fields("JobCode5") = JCC5
            .Fields("WorkRule5") = WR5
            .Fields("WageType5") = WageType5
            .Fields("CostCenter5") = CC5
            .Fields("ImportSource") = ImportSource
--> On this row           .Fields("ImportStatus") = ImportStatus
            .Fields("LastUpdated") = LastUpdated
        .Update
    End With
   
    Set rs = Nothing
    Set con = Nothing
    ''''Set wsp = Nothing
   
End Sub
0
Comment
Question by:dminx13
  • 4
  • 3
8 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 39639605
Usually when I get this, it's because I'm trying to stuff a string into a field that's too small.

Check the data your trying to insert on all your text fields.

Jim.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39639607
what data types are the fields "Status" and "ImportStatus"

if numbers, change the way you declare the variables

Status As String,  change to Status As integer

ImportStatus As String change to  ImportStatus As integer

if it is a Yes/No field  change the variables accordingly to Boolean
0
 
LVL 57
ID: 39639612
By the way, you can find out quickly enough by adding some error handling.

Then place a stop at the top of the procedure.  Execute it.  When you hit the stop, use F8 to step through the code slowly until you jump to the error handler.  The last line executed caused the error.

Jim.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 57
ID: 39639616
Sorry, just caught this:

--> On this row           .Fields("ImportStatus") = ImportStatus

 Check the field length/type.

Jim.
0
 

Author Comment

by:dminx13
ID: 39639621
Status is passed as "Active" all the time. And ImportStatus is being passed as "New" all the time. So they are both strings. I've got other fields that are set up the same way: PeriodCycle - "B", ShiftSchedule - "01", Source - "Recruit", and ImportSource - "Recruit" So why are these 2 strings giving me issues?

    Call ExportToTimeTrac(strID, Now(), BadgeNumber, Hire.Fields("FirstName"), _
                    Hire.Fields("LastName"), " ", strSupervisor, "Active", strEmployeeGroup, _
                    "B", "01", "Recruit", strScheduleImport, strScheduleType, 0, 0, _
                    strJCC(0), strWR(0), strWageType(0), strCC(0), _
                    strJCC(1), strWR(1), strWageType(1), strCC(1), _
                    strJCC(2), strWR(2), strWageType(2), strCC(2), _
                    strJCC(3), strWR(3), strWageType(3), strCC(3), _
                    strJCC(4), strWR(4), strWageType(4), strCC(4), _
                    "Recruit", "New", Now())

Public Sub ExportToTimeTrac(ID As String, ImportDate As Date, BadgeNumber As String, _
                            FirstName As String, LastName As String, MiddleInitial As String, _
                            Supervisor As String, Status As String, EmployeeGroup As String, _
                            PeriodCycle As String, ShiftSchedule As String, Source As String, _
                            ScheduleImport As String, ScheduleType As String, Vacation As Single, _
                            Sick As Single, _
                            JCC1 As String, WR1 As String, WageType1 As String, CC1 As String, _
                            JCC2 As String, WR2 As String, WageType2 As String, CC2 As String, _
                            JCC3 As String, WR3 As String, WageType3 As String, CC3 As String, _
                            JCC4 As String, WR4 As String, WageType4 As String, CC4 As String, _
                            JCC5 As String, WR5 As String, WageType5 As String, CC5 As String, _
                            ImportSource As String, ImportStatus As String, LastUpdated As Date)
0
 

Author Comment

by:dminx13
ID: 39639629
As a side note, this worked when we were using ODBC calls. We had to update to ADO and now it is throwing errors on those 2 fields. You can see that commented out on the code.
0
 

Author Closing Comment

by:dminx13
ID: 39639716
UG!!!!! Didn't know where the data was going but this was right. The table was 1 character long and was getting data that was too long. I updated to be 1 character and it works perfectly now! Not sure why it was working before though. Maybe it was just trimming it??
0
 
LVL 57
ID: 39639719
<<Status is passed as "Active" all the time. And ImportStatus is being passed as "New" all the time. >>

  You sure those values are trimmed?   As a test, try hardcoding the letter "A" and "N" for the fields and see if it works.

Jim.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question