hi buddy
here's the sample code tht i am using.
HENV hEnv = NULL;
HDBC hDbc = NULL;
HSTMT hStmt = NULL;
UCHAR szDSN[SQL_MAX_DSN_LENGTH] = "himanshuDSN";
char szmodel[128];
char szmodel1[128];
char szmodel2[128];
SDWORD cbmodel;
SDWORD cbmodel1;
SDWORD cbmodel2;
RETCODE retcode;
//Query statement
UCHAR sql1[] = "Select subcode from registration where rollno=";
UCHAR sql2[] = "Select subcode from registration where rollno=";
int i,j,no = 1;
int rno;
char s[10];
SQLAllocEnv(&hEnv);
SQLAllocConnect(hEnv,&hDbc);
retcode = SQLConnect(hDbc,szDSN,SQL_NTS,'\0',SQL_NTS,'\0',SQL_NTS);
printf("Enter the roll no : ");
scanf("%d",&rno);
itoa(rno,s,10);
strcat(sql1,s);
if(retcode == SQL_SUCCESS|| retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLAllocStmt(hDbc,&hStmt);
retcode = SQLPrepare(hStmt,sql1,sizeof(sql1));
retcode = SQLExecute(hStmt);
printf("\nReading the records\n");
SQLBindCol(hStmt,no,SQL_C_CHAR,szmodel,sizeof(szmodel),&cbmodel);
//SQLBindCol(hStmt,no+1,SQL_C_CHAR,szmodel1,sizeof(szmodel1),&cbmodel1);
//SQLBindCol(hStmt,no+2,SQL_C_CHAR,szmodel2,sizeof(szmodel2),&cbmodel2);
retcode = SQLFetch(hStmt);
while(retcode == SQL_SUCCESS|| retcode == SQL_SUCCESS_WITH_INFO)
{
printf("\t%s \n",szmodel,szmodel1,szmodel2);
retcode = SQLFetch(hStmt);
}
SQLFreeStmt(hStmt,SQL_DROP);
SQLDisconnect(hDbc);
}else{
printf("Can not read the database\n");
}
SQLFreeConnect(hDbc);
SQLFreeEnv(hEnv
how are you connecting? if you're just using straight odbc, you'll have to use the odbc functions to return the error messages. Using CRecordset you can probably get them through your CException-derived class counterparts. If you're using straight odbc I have some code that I could post back to give you an example. let me know