Problems if ODBC connection

Hi,

I have problem with connecting to Navision Native DB thought ODBC.
I wrote simple program that connects to Navision DB thought ODBC, it works fine. Then - extended stored procedure for SQL server, but it throws exception then connecting DB

.........
dbconnect->OpenEx("Database=C:\\Navision Attain\\Client\\database.fdb;RD=No;DSN=NavisionDB;CSF=No;CN=CRONUS Lithuania u.a.b.;CC=Yes;OPT=Text;CD=No;ML=1063;SERVER=N;BE=Yes;IT=All Except DOT;PPath=C:\\Navision Attain\\Client;QTYesNo=Yes;RO=No",CDatabase::noOdbcDialog);
......

Exception: ex->m_strError == -1
ex->m_strError == „ISAM error“

What does it mean?
And more, if connect string is
“MaxBufferSize=2048;FIL=MS Access;DSN=UsersDB;PageTimeout=5;UID=admin;DBQ=D:\\WORK\\JAVA\\DATABASE\\Users.mdb;DriverId=25”
– Access DB then every thing works fine, xp too.

I don’t get it, what’s wrong?
AshooTAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CluskittCommented:
> Database=C:\\Navision Attain\\Client\\database.fdb
fdb? was that a typo posting here, or is it a typo in your program? There are several programs that crete databases with the FDB extension, on the correct connect string you have .mdb, so I assume it's a typo.
If it's a typo here, then please try to paste the correct exact connection string. If it's a typo in the program, then that could be the cause.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AshooTAuthor Commented:
.fdb it is Navision Attain Native Database. And connection string here is correct, because I can connect with it in my program, but then the same code in extended stored procedures – crashes. :((
Thanks any way!!!
0
CluskittCommented:
Can you post the procedures here? The problem could be in the procedure itself, not in the connection string.
In fact, if you say you can do it with your program, then it must be in the procedures.
Anyway, can you post the code so we can try to find something wrong with it, please?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

AshooTAuthor Commented:
Ok, np =)
CODE:

#include <string.h>
#include <afxdb.h>
#include <atlstr.h>
#include <Srv.h>
#include <stdio.h>
#include "XP_GetNavisionTable.h"


SRVRETCODE  xp_getnavisiontable(SRV_PROC* srvproc);
ULONG __GetXpVersion();
void printMessage(SRV_PROC *pSrvProc, CHAR* message);


ULONG __GetXpVersion()
{
    return ODS_VERSION;
}

SRVRETCODE  xp_getnavisiontable(SRV_PROC* srvproc)
{
                DBCHAR colname[500];
   
      //_snprintf(colname, MAXCOLNAME, "Text");
      //srv_describe(srvproc, 1, colname, SRV_NULLTERM, SRVCHAR, MAXNAME,
                //                    SRVCHAR, 0, NULL);

//////////////////////////
      printMessage(srvproc, "1");
      CString varValue;

      CDatabase *dbconnect = new CDatabase();
      printMessage(srvproc, "2");

      try
      {
            dbconnect->OpenEx("Database=C:\\Navision Attain\\Client\\database.fdb;RD=No;DSN=NavisionDB;CSF=No;CN=CRONUS Lithuania u.a.b.;CC=Yes;OPT=Text;CD=No;ML=1063;SERVER=N;BE=Yes;IT=All Except DOT;PPath=C:\\Navision Attain\\Client;QTYesNo=Yes;RO=No",CDatabase::noOdbcDialog);
            printMessage(srvproc, "3");
      } catch (CDBException *ex) {
            printMessage(srvproc, "Error: connection Navision DB");
            _snprintf(colname, 500, "%s %s\nError code: %i",
                              ex->m_strStateNativeOrigin.GetBuffer(),
                              ex->m_strError.GetBuffer(),
                              ex->m_nRetCode);
            printMessage(srvproc, colname);
            return XP_ERROR;
      }

      CRecordset *record = new CRecordset(dbconnect);
      record->Open(CRecordset::forwardOnly, "SELECT * FROM Pirk&#279;jas");
      printMessage(srvproc, "4");

      short nFields = record->GetODBCFieldCount();
      printMessage(srvproc, "5");
      while( !record->IsEOF( ) )
      {
            for( short index = 0; index < nFields; index++ )
          {
                  record->GetFieldValue( index, varValue );
                                      ///...
                  /// printig
                  ///...
            }
            record->MoveNext( );
      }
      printMessage(srvproc, "6");

      delete record;
      delete dbconnect;
      printMessage(srvproc, "7");
//////////////////////////      

               //srv_sendrow(srvproc);

      srv_senddone(srvproc, SRV_DONE_MORE | SRV_DONE_COUNT, (DBUSMALLINT)0, 0);

      return  XP_NOERROR;
}

void printMessage(SRV_PROC *pSrvProc, CHAR* message)
{
    srv_sendmsg(pSrvProc, SRV_MSG_INFO , 0, SRV_INFO, 1,
                  NULL, 0, (DBUSMALLINT) __LINE__,
                    message,
                      SRV_NULLTERM);
}

This is my tiny stored procedure,
If you fide an error or soliution it would be greate!!! Because I looking for soliution all this week :((
0
CluskittCommented:
Can you also insert the code for XP_GetNavisionTable.h? Since the procedure seems to be loading from definitions there, the error could be there, or, at least, it could help understand where the error might be coming from.
0
AshooTAuthor Commented:
Sure  Cluskitt:
//*******************************************************************
//                              File : XP_GetNavisionTable.h
//*******************************************************************
#define XP_NOERROR      0
#define XP_ERROR        1

#define MAXCOLNAME                        25
#define MAXNAME                              25
#define MAXTEXT                              255

#ifdef _MSC_VER
#define DBL_CDECL                    __cdecl
#else
#define DBL_CDECL                    _cdecl
#endif

#define MAX_SERVER_ERROR         20000

//*******************************************************************
//                              File : XP_GetProcedureDefinition.def
//*******************************************************************
LIBRARY      XP_GetNavisionTable

EXPORTS
      xp_getnavisiontable
      __GetXpVersion

All files naw here :))
0
CluskittCommented:
Ok, I will check on that and reply to you this weekend. With some luck, tonight. I'm at work now and having a busy day, so I can't really focus on that now, but I already printed it and will check it on my way home on the train! ;-)
0
AshooTAuthor Commented:
Oki, Thanks Cluskitt!!!
I have a really greate headache with thid dll ;)))
0
CluskittCommented:
Ok, I couldn't find an error, as your code is above my knowledge, but I passed your question to an "expert" I know! As soon as I have an answer, I'll let you know! ;-)
BTW, you're using VC++, right?
0
AshooTAuthor Commented:
Yep, I using VC++ .NET
I asked some "experts" too, but still didn't get any answers or they couldn't help me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.