Solved

Problems if ODBC connection

Posted on 2003-11-19
11
1,329 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:AshooT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 18

Accepted Solution

by:
Cluskitt earned 200 total points
ID: 9786406
> 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
 

Author Comment

by:AshooT
ID: 9786614
.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
 
LVL 18

Expert Comment

by:Cluskitt
ID: 9786646
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:AshooT
ID: 9786805
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
 
LVL 18

Expert Comment

by:Cluskitt
ID: 9786937
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
 

Author Comment

by:AshooT
ID: 9795177
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
 
LVL 18

Expert Comment

by:Cluskitt
ID: 9796279
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
 

Author Comment

by:AshooT
ID: 9809279
Oki, Thanks Cluskitt!!!
I have a really greate headache with thid dll ;)))
0
 
LVL 18

Assisted Solution

by:Cluskitt
Cluskitt earned 200 total points
ID: 9817255
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
 

Author Comment

by:AshooT
ID: 9817607
Yep, I using VC++ .NET
I asked some "experts" too, but still didn't get any answers or they couldn't help me.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Six Sigma Control Plans

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question