Access violation error using Sql Router and Sql Server

General discussion forum about all databases other than SqlBase.
perkinda

Access violation error using Sql Router and Sql Server

Post by perkinda » 22 Mar 2012, 17:35

Can you provide any insight into why I am getting an access violation error with the code below?
The database is Sql Server 2008 and the three database columns are varchar(3), varchar(1) and varchar(3) respectively.
If I use use SQLPLVR parameter with sqlbnn2 I get an error on sqlexe and no data is inserted into the database.
If I use SQLPBUF, I do not get the error until after the last line. In the latter rcd is always zero, indicating success - and I do get an insert into the database.

The error is
Unhandled exception at 0x0047d349 in DocPrintTest.exe: 0xC0000005: Access violation reading location 0x00000340.

Code: Select all

[code]// DocPrintTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <TCHAR.H>
#include <comdef.h>
#include <sql32.h>

int _tmain(int argc, _TCHAR* argv[])
{
   SQLTCUR cur = 0;
   LPCTSTR dbname = _T("QA_CMIC2/PHX/TOEHOLD");
   SQLTRCD rcd = sqlcnc(&cur, SQLTDAP(dbname), 0);
   
   //LPCTSTR statement = _T("INSERT INTO DEC_LAYOUT (DOC_LAYOUT_TYPE, POL_TYPE, DOC_TYPE) VALUES ('0DP', ' ', 'BI1')");
   LPCTSTR statement = _T("INSERT INTO DOC_LAYOUT_TEST (DOC_LAYOUT_TYPE, POL_TYPE, DOC_TYPE) VALUES (:1, :2, :3)");
   rcd = sqlcom(cur, SQLTDAP(statement), lstrlen(statement));

   LPCTSTR values[] = {
      _T("0DP"), _T(""), _T("BI1")   
   };
   int n = sizeof(values)/sizeof(values[0]);
   for(int i = 0; i < n; i++)
   {
      rcd = sqlbnn2(cur, i + 1, SQLTDAP(values[i]), lstrlen(values[i]), 0, SQLPBUF);//SQLPLVR);
   }

   rcd = sqlexe(cur);
   rcd = sqldis(cur);
   return 0;
}
[/code]

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 6 guests