Error when Getting Migration SQL: Missing .idx file

dwilliamsdwilliams Posts: 6
edited September 13, 2006 11:48AM in SQL Toolkit Previous Versions
When attempting to Get the migration sql for execution, I am getting a "Could not find file" error. It appears to be looking for an .idx file. Shorter data comparisons do not generate this error. It appears if the number of changes are large (as they are in this case) GetMigrationSql attempts to write to a specific file, however this file is not found? I also tried setting the environment variable to write to a differenct location (c:\temp) however the same error occured (with the new file location).

The error and abreviated stack trace are below.

Could not find file 'C:\Documents and Settings\(username)\Local Settings\Temp\RGDC-f5d43482-dfbc-4976-bebd-31e224f6e5f8.2.idx'.
at System.IO.__Error.WinIOError...
at System.IO.FileStream.Init...
at System.IO.FileStream..ctor...
...
at RedGate.SQLDataCompare.Engine.SqlProvider.GetMigrationSQL...
...

The code I am running is as follows. This appears to fail when calling GetMigrationSQL
private void ExecuteDataSyncScript(ComparisonSession cmpSession)
{
    SqlProvider provider = new SqlProvider();
    using (ExecutionBlock block = provider.GetMigrationSQL(cmpSession, true))
    {
        // Update Changes
        BlockExecutor executor;
        executor = new BlockExecutor();
        executor.ExecuteBlock(block, _ServerName, _DatabaseName);
    }
}
The session is created as follows:
cmpSession = new ComparisonSession();
    cmpSession.CompareDatabases(dbSource, dbTarget, mappings);

Comments

  • Hi,

    The last time this happened, it was because the user was running the dispose() method on the session before invoking the method that produces the synchronization script. In this case, the temporary files needed to generate the SQL are deleted and this error results.
  • The last time this happened, it was because the user was running the dispose() method on the session before invoking the method that produces the synchronization script. In this case, the temporary files needed to generate the SQL are deleted and this error results.
    Close. While comparing databases, I am looping through the TableDifferences collection, displaying table changes info. I was disposing of the (single) TableDifference object. Commenting this out fixed the problem. Thanks. :D
    foreach (TableDifference tblDiff in session.TableDifferences)
    {
        // Display table difference info using tblDiff
        tblDiff.Dispose();  // Removing this line fixed the problem
    }
    // GetMigration SQL, etc.
    
  • That would do it!
Sign In or Register to comment.