Solved

Problems if ODBC connection

Posted on 2003-11-19
11
1,313 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
  • 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now