From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

cvi mysql access database

Using CVI 9.0.1, using a 32 c# .dll, that I imported into my design using the .net import tool. When I try to create a database object I get this error msg:       

  message = Could not load file or assembly 'MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

Here is my code

    int retVal;

    char * message = NULL;
    char * source = NULL;
    char * trace = NULL;   
    char * help = NULL;
    char * target = NULL;
    char * dbPtr = NULL;
    char * SQLptr = NULL;
    char * record = NULL;
    VBOOL connectFlag;
    
    /* dot net variables */
    //////////////////////////////////////////
    sbCommonFunctions_Database dbHandle;
    CDotNetAssemblyHandle DotNetHandle;
    CAObjHandle databaseObj = 0;
    CDotNetHandle dnHandle;
    /////////////////////////////////////////

    char dbLocation[] = "c:\\obsoleteparts.mdb"    ;

    dbPtr =  dbLocation;
    SQLptr = sqlStr;
    errorTxt[0] = 0;

    // register assembly files
    retVal = CDotNetRegisterAssemblyPath("mscorlib","C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\mscorlib.dll");
    retVal = CDotNetRegisterAssemblyPath("System.Data","C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\System.Data.dll");    
    retVal = CDotNetRegisterAssemblyPath("System","C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll");    
    retVal = CDotNetRegisterAssemblyPath("System.Drawing","C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\System.Drawing.dll");    
    retVal = CDotNetRegisterAssemblyPath("ADODB","C:\\Windows\\assembly\\GAC\\ADODB\\7.0.3300.0__b03f5f7f11d50a3a\\ADODB.dll");    
    retVal = CDotNetRegisterAssemblyPath("MySql.Data","C:\\Etest_version_NI\\sbcommonfunctions\\x86\\mysql.data.dll");   
    retVal = CDotNetRegisterAssemblyPath("log4net","C:\\Etest_version_NI\\sbcommonfunctions\\x86\\log4net.dll");
    retVal = CDotNetRegisterAssemblyPath("MySql.Data.Entity","C:\\Etest_version_NI\\sbcommonfunctions\\x86\\MySql.Data.Entity.dll");   
    retVal = CDotNetRegisterAssemblyPath("MySql.Web","C:\\Etest_version_NI\\sbcommonfunctions\\x86\\MySql.Web.dll");
    retVal = CDotNetRegisterAssemblyPath("MySql.Data.CF","C:\\Etest_version_NI\\sbcommonfunctions\\x86\\MySql.data.cf.dll");  
      
    // load assembly files
    retVal = CDotNetLoadAssembly("mscorlib",&DotNetHandle);
    retVal = CDotNetLoadAssembly("System.Data",&DotNetHandle);    
    retVal = CDotNetLoadAssembly("System",&DotNetHandle);    
    retVal = CDotNetLoadAssembly("System.Drawing",&DotNetHandle);    
    retVal = CDotNetLoadAssembly("ADODB",&DotNetHandle);    
    retVal = CDotNetLoadAssembly("MySql.Data",&DotNetHandle);    
    retVal = CDotNetLoadAssembly("log4net",&DotNetHandle);
    retVal = CDotNetLoadAssembly("MySql.Data.Entity",&DotNetHandle);
    retVal = CDotNetLoadAssembly("MySql.Web",&DotNetHandle);
    retVal = CDotNetLoadAssembly("MySql.Data.CF",&DotNetHandle);

    // init .net dll
    retVal = Initialize_sbCommonFunctions ();
    // create database object (FAILURE OCCURS HERE)
    retVal = sbCommonFunctions_Database__Create_2 (&dbHandle, dbPtr, &dnHandle);
    retVal = CDotNetGetExceptionInfo(dnHandle,0,&message,&source,&trace,&target,&help);

 

I manual load all the assembly files, as shown in the code. I have also registered the .dll through regasm. I also tried dropping all of the files into c:\windows\syswow64, and ran into the same issue. Computer is running Windows 7 64-bit, .dll uses .net 3.5 & 2.0 components. Any ideas would be great I am pretty stumped at this point.

-Justin

0 Kudos
Message 1 of 2
(4,142 Views)

Hi klumppster,

 

Can you open up MySql.Data in the MySQL Workbench?  It could be something with the ODDC or OLE driver, depending on what you are using.  Can you post the MySQL.data file so I can look at it?

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(4,092 Views)