Solved

Problems if ODBC connection

Posted on 2003-11-19
11
1,322 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is an explanation of a simple data model to help parse a JSON feed
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

860 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