64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
#ifndef _SQL_ERROR_HPP_
|
|
#define _SQL_ERROR_HPP_
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
#ifndef _SQL_SQLSTATEMENT_HPP_
|
|
#include <sql/sqlstmt.hpp>
|
|
#endif
|
|
|
|
class SQLErr
|
|
{
|
|
public:
|
|
SQLErr(void);
|
|
virtual ~SQLErr();
|
|
void sqlErr(const SQLStatement &sqlStatement);
|
|
void sqlErr(const SQLStatement &sqlStatement,String &strResult);
|
|
void sqlErr(void);
|
|
private:
|
|
enum {MaxErrorLength=512};
|
|
};
|
|
|
|
inline
|
|
SQLErr::SQLErr(void)
|
|
{
|
|
}
|
|
|
|
inline
|
|
SQLErr::~SQLErr()
|
|
{
|
|
}
|
|
|
|
inline
|
|
void SQLErr::sqlErr(const SQLStatement &sqlStatement)
|
|
{
|
|
String sqlMessageString;
|
|
SWORD outlen;
|
|
|
|
sqlMessageString.reserve(MaxErrorLength+1);
|
|
::SQLError(0,0,(SQLStatement&)sqlStatement,0,0,(UCHAR*)(LPSTR)sqlMessageString,MaxErrorLength,&outlen);
|
|
::MessageBox(::GetFocus(),(LPSTR)sqlMessageString,(LPSTR)"SQLERROR",MB_OK);
|
|
}
|
|
|
|
inline
|
|
void SQLErr::sqlErr(const SQLStatement &sqlStatement,String &strResult)
|
|
{
|
|
SWORD outlen;
|
|
|
|
strResult.reserve(MaxErrorLength+1);
|
|
::SQLError(0,0,(SQLStatement&)sqlStatement,0,0,(UCHAR*)(LPSTR)strResult,MaxErrorLength,&outlen);
|
|
}
|
|
|
|
inline
|
|
void SQLErr::sqlErr(void)
|
|
{
|
|
String sqlMessageString;
|
|
String sqlState;
|
|
SWORD outlen;
|
|
|
|
sqlMessageString.reserve(MaxErrorLength+1);
|
|
::SQLError(0,0,0,(UCHAR*)(LPSTR)sqlState,0,(UCHAR*)(LPSTR)sqlMessageString,MaxErrorLength,&outlen);
|
|
::MessageBox(::GetFocus(),(LPSTR)sqlState,(LPSTR)"SQLERROR",MB_OK);
|
|
}
|
|
#endif
|