Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


xedarius
2009-07-14T17:25:11Z
Hi,

I'm currently trialing your software as a replacement to some software we currently use to control services/processes/reports.

However I'm trying to start one of our processes, one which uses ODBC.

I have filled in the credentials .. however the process doesn't seem to start correctly. I get the following error in our log file;

Fatal| ODBC Error: Specified driver could not be loaded due to system error 126 (Oracle dans ORACLE_10g).

I suspect this could be something to do with environment variables. However I'm unsure.

Any ideas on how to fix this?


Cheers
Rich Carless
Sponsor
Forum information
Support
2009-07-14T18:17:36Z
What type of SQL Connection do you use?

It seems that you are using ODBC with and ODBC connection string. If you do that you need to specify the exact driver name in connection string as you find in your local ODBC.

But, if you are using Oracle, you will get higher speed by using:

* Database type: Oracle
* Provider: Oracle

This option will use native Oracle driver instead of ODBC.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T09:58:21Z
I dont think it's an issue with the connection string as when I run the process from the shell (ie by double clicking it). It runs just fine.

However thanks for the tip about the oracle driver ... I'll investigate that.

Any further ideas on why it might not run the process via VisualCron?
Support
2009-07-15T10:06:46Z
It depends on how you created the Connection. If you used the guide I am almost 100% sure that it is just the wrong version of ODBC driver (as the error specifies) when comparing the connection string and what you see in ODBC viewer. You probably just have to edit the Connection and change a number in it to get it to work.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T10:15:30Z
Ah I see why the driver string looks confusing. I work for a French company the driver string does match the ODBC driver in my ODBC control pannel.

Also the app has been working for several years. The only time it doesn't work is when I run it via VisualCron.

This indicates to me that there's something missing from the process launch.

Oracle needs access to the environment variables (at least when used from MFC), do you launch with all the system variables set?

Cheers
Rich
Support
2009-07-15T10:23:28Z
I am not 100% of that. Please try this and we can work from there.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T10:37:21Z
Ok I've written a test app. The test app connects to the database, when I run via visual cron it does not.

Note the commented out connection string (the one you suggested) when I try this I can't connect to the database either via debugging or through visual cron.


Here's the code .. note I've blanked the password out!


// ODBCDriverTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "ODBCDriverTest.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#pragma comment(lib, "odbc32.lib")

// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;


   SQLHENV henv;
   SQLHDBC hdbc;
   SQLHSTMT hstmt;
   SQLRETURN retcode;
   SQLPOINTER rgbValue;
   int i = 5;
   rgbValue = &i;

   SQLCHAR OutConnStr[512];
   SQLSMALLINT OutConnStrLen;

   HWND desktopHandle = GetDesktopWindow();   // desktop's window handle

   // Allocate environment handle
   retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);

   // Set the ODBC version environment attribute
   if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
   {
      retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0); 

      // Allocate connection handle
      if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
	  {
         retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); 

         // Set login timeout to 5 seconds
         if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
		 {
            SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(rgbValue), 0);

			const char *con_string = "DRIVER={Oracle dans ORACLE_10g};UID=xxxxxxx;PWD=xxxxxxx;DBQ=xxxxxxx;GDE=T";
//			const char *con_string = "Provider=Oracle;Database type= Oracle;UID=xxxxxx;PWD=xxxxxxx;DBQ=xxxxxx;GDE=T";

            retcode = SQLDriverConnect( // SQL_NULL_HDBC
               hdbc, 
               desktopHandle, 
               (SQLCHAR*)con_string, 
               strlen(con_string),
               OutConnStr,
               512, 
               &OutConnStrLen,
               (SQLUSMALLINT)SQL_DRIVER_COMPLETE_REQUIRED );

            // Allocate statement handle
            if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
			{               
               retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); 

			   MessageBox(desktopHandle,"Success!","ODBC Driver loaded!",MB_OK);
               // Process data
               if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
			   {
                  SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
               }

               SQLDisconnect(hdbc);
            }
			else
			{
			   MessageBox(GetDesktopWindow(),"Failed!","ODBC Driver connect",MB_OK);
			}

            SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
         }
      }
      SQLFreeHandle(SQL_HANDLE_ENV, henv);
   }

	return nRetCode;
}

Support
2009-07-15T10:41:22Z
Why do you not use the SQL Task?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T10:47:18Z
We don't use an SQL task as we construct thousands of dynamic queries.

What we do with the SQL connection isn't really important in terms of this problem.

The main problem is: why the sample code above works when run from the command line, and yet doesn't run when executed by Visual Cron.

Sorry if it sounds like I'm repeating myself, but do you know why?

Cheers
Rich
Support
2009-07-15T12:32:52Z
I think the main problem is that you try to use a desktopHandle. Please note that by default we are running the process from a Windows service (no desktop). Try changing to Foreground in Task main settings.

A side note. You can create dynamic queries with SQL Task by using Variables and pass information. The main reason I am stressing this is because it is more efficient to use the native driver than to Start a process and then call a ODBC driver.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T12:43:07Z
Changing the task to a foreground task has made everything work!

Thank you.


I'm not clear on how to instaniate the native driver. I'd like to take advantage of the performance, however I tried changing the connection string as you suggested and that didn't work.

Can I also point out that the database code is a subsection of a massive system. So changes would need to made at this point as refactoring code is not an option for us.

If you'd care to detail the connection string to use I'd be very grateful.

Cheers
Rich
Support
2009-07-15T13:16:05Z
We can only offer details how to use the Native driver from VisualCron. Which is very easy. Just create a Connection in VisualCron. Use the Connection guide. Use Database type Oracle and provider Oracle. Enter your username/password in next dialog.

Now you create a SQL Task. Enter any SQL or use Variable if you want to make it dynamic.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T13:52:20Z
Ah I understand what you're refering to, it's the .NET Oracle Provider.

Sadly this doesn't exist in native c++/MFC.

Thanks for your help.

Rich
Support
2009-07-15T14:42:22Z
We are using the .NET provider - but I am not refering to that one. I am still refering to using the SQL Task instead of executable (even though that one uses the .NET provider).
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T14:51:21Z
We're not just firing off a bunch of SQL in a task then shutting down. We have an entire system that listens to network messages and responds to multiuser requests and backs the information in a database.

SQL Task sounds like a one shot executable designed to run SQL. You are talking about a seperate exe aren't you?

If not could to please provide me with a link on MSDN to SQL Task - as I seem unable to locate any information other than with reference to SQL server ...
Support
2009-07-15T15:38:50Z
I think you have misunderstood the definitions within VisualCron. The SQL Task is a part of VisualCron and has nothing to do with MSDN or similar. Yes, it fires of any type of SQL or SQL JOB, SSIS etc.

I know nothing about your exe or when you launch it. It just seems, for me, that you want to launch it when you want to do something (not that you have it running all the time). And if so, it seems more effiecent to use the built in SQL Task in VisualCron to perform the work.

The big question is when you launch something (based on what). And what you want to do. Based on this information one can decide what can be automated in VisualCron (without having to program anything).
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
xedarius
2009-07-15T15:45:29Z
Ah now I understand .. I think we've been talking cross purposes.

In our setup the SQL task within VisualCron would not help us in this situation.

Thanks
Rich Carless
Scroll to Top