11-06-2015 04:57 AM
Hello,
I'm trying to open and read a table of database access (2007) protected by a password. I'm using Labwindows/CVI2012.
The problem is that I'm getting this error in "DBConnect" function :
DBConnect - NON-FATAL RUN-TIME ERROR: Function DBConnect: (return value == -10 [0xfffffff6]). Native error code -2147217843 0x80040e4d Microsoft JET Database Engine:
Can not start your application. The workgroup information file is missing or opened exclusively by another user.
My code is really simple : I'm calling the "ConnectBase" function using my "Index" parameter (wich is 3 in my case)
ConnectBase(int iIndex, char * BaseName) { int error=0,i=0; //char tcTestCheminDB[MAX_PATH_LENGTH]=""; //DB Globale char tcDBGlobalPath[MAX_PATH_LENGTH]=""; //DB Globale char tcDBProjPath[MAX_PATH_LENGTH]=""; //DB Projet char tcReportText[200]; (1000 * sizeof(char)); switch(iIndex) { case 0: case 1: case 2: case 3: //HA Modification 05/11/2015 sprintf(Connection_DB_Texem_Local,""); GetDatabasePath (BaseName, tcReportText, tcDBProjPath, 0); strcat (Connection_DB_Texem_Local, "Provider=Microsoft.Jet.OLEDB.4.0;Password=JEmxa07<;Data Source="); for (i = 0 ; i < strlen(tcDBProjPath) ; i ++) { if (tcDBProjPath[i] == 92) { strcat (Connection_DB_Texem_Local,"\\"); } else { Connection_DB_Texem_Local[strlen(Connection_DB_Texem_Local) + 1] = 0; Connection_DB_Texem_Local[strlen(Connection_DB_Texem_Local)] = tcDBProjPath[i]; } } strcat (Connection_DB_Texem_Local,";Mode=ReadWrite;Persist Security Info=False;"); //Use simple Thread ErrChk_DB(DBInit (DB_INIT_MULTITHREADED)); //Connect to the DB // ErrChk_DB(tiConnectionHandle[iIndex] = DBConnect (CONNEXION_BASE)); if(tiConnectionHandle[iIndex]>0) { DisConnectBase(iIndex); ErrChk_DB(tiConnectionHandle[iIndex] = DBConnect (Connection_DB_Texem_Local)); } else { //DisConnectBase(iIndex); ErrChk_DB(tiConnectionHandle[iIndex] = DBConnect (Connection_DB_Texem_Local)); } break; } return 1; Error: return error; }
The error is happening in the red line.
Any idea please to solve that ?
11-08-2015 11:55 PM
What is the function of DisConnectBase() ? Could you show us the code ?
The error says that you try to open an already opened database and according to its naming DisConnectBase() may close the database so that the problem doesn't happen in the other case of your if statement
11-09-2015 08:01 AM - edited 11-09-2015 08:11 AM
DisConnectBase(int iIndex) { int error = 0; if (tiConnectionHandle[iIndex]>0) { ErrChk_DB(DBDisconnect (tiConnectionHandle[iIndex])); tiConnectionHandle[iIndex] = -1; } return 1; Error: tiConnectionHandle[iIndex] = -1; return error; }
11-09-2015 08:02 AM - edited 11-09-2015 08:11 AM
Besides, I think that tiConnectionHandle[iIndex] condition is not good.
I have 3 DB connection. tiConnectionHandle is a table where I should pour the reslut of each DBConnect(handle) of the three connection.
NOTE : It's 3 different DB.