catsets.cpp
资源名称:ISQL_src.zip [点击查看]
上传用户:jsxglz
上传日期:2007-01-03
资源大小:117k
文件大小:3k
源码类别:
SQL Server
开发平台:
Visual C++
- // GetTypeInfo.cpp: implementation of the CGetTypeInfo class.
- //
- #include "stdafx.h"
- #include "catsets.h"
- /////////////////////////////////////////////////////////////////////////////
- // CGetTypeInfo
- CGetTypeInfo::CGetTypeInfo(CDatabase* pDatabase)
- : CRecordset(pDatabase)
- {
- m_strTypeName = _T("");
- m_fDataType = 0;
- m_nPrecision = 0;
- m_strLiteralPrefix = _T("");
- m_strLiteralSuffix = _T("");
- m_strCreateParams = _T("");
- m_fNullable = 0;
- m_bCaseSensitive = 0;
- m_fSearchable = 0;
- m_fUnsignedAttribute = 0;
- m_bMoney = 0;
- m_fAutoIncrement = 0;
- m_strLocalTypeName = _T("");
- m_nMinimumScale = 0;
- m_nMaximumScale = 0;
- m_nFields = 15;
- }
- BOOL CGetTypeInfo::Open(short fSqlType, UINT nOpenType)
- {
- RETCODE nRetCode;
- UWORD bFunctionExists;
- // make suer SQLGetTypeInfo exists
- AFX_SQL_SYNC(::SQLGetFunctions(m_pDatabase->m_hdbc,
- SQL_API_SQLGETTYPEINFO,&bFunctionExists));
- if (!Check(nRetCode) || !bFunctionExists)
- {
- if (!bFunctionExists)
- TRACE(_T("SQLGetTypeInfo not supportedn"));
- return FALSE;
- }
- // Cache state info and allocate hstmt
- SetState(nOpenType, NULL, readOnly);
- if(!AllocHstmt())
- return FALSE;
- TRY
- {
- OnSetOptions(m_hstmt);
- // Build SQL and prep/execute or just execute direct
- AllocStatusArrays();
- // call the ODBC function
- AFX_SQL_ASYNC(this,::SQLGetTypeInfo(m_hstmt,fSqlType));
- if (!Check(nRetCode))
- ThrowDBException(nRetCode,m_hstmt);
- // Allocate memory and cache info
- AllocAndCacheFieldInfo();
- AllocRowset();
- // Fetch the first row of data
- MoveNext();
- // If EOF, then result set empty, so set BOF as well
- m_bBOF = m_bEOF;
- }
- CATCH_ALL(e)
- {
- Close();
- THROW_LAST();
- }
- END_CATCH_ALL
- return TRUE;
- }
- void CGetTypeInfo::DoFieldExchange(CFieldExchange* pFX)
- {
- pFX->SetFieldType(CFieldExchange::outputColumn);
- RFX_Text(pFX, _T("TYPE_NAME"), m_strTypeName);
- RFX_Int(pFX, _T("DATA_TYPE"), m_fDataType);
- RFX_Long(pFX, _T("PRECISION"), m_nPrecision);
- RFX_Text(pFX, _T("LITERAL_PREFIX"), m_strLiteralPrefix);
- RFX_Text(pFX, _T("LITERAL_SUFFIX"), m_strLiteralSuffix);
- RFX_Text(pFX, _T("CREATE_PARAMS"), m_strCreateParams);
- RFX_Int(pFX, _T("NULLABLE"), m_fNullable);
- RFX_Int(pFX, _T("CASE_SENSITIVE"), m_bCaseSensitive);
- RFX_Int(pFX, _T("SEARCHABLE"), m_fSearchable);
- RFX_Int(pFX, _T("UNSIGNED_ATTRIBUTE"), m_fUnsignedAttribute);
- RFX_Int(pFX, _T("MONEY"), m_bMoney);
- RFX_Int(pFX, _T("AUTO_INCREMENT"), m_fAutoIncrement);
- RFX_Text(pFX, _T("LOCAL_TYPE_NAME"), m_strLocalTypeName);
- RFX_Int(pFX, _T("MINIMUM_SCALE"), m_nMinimumScale);
- RFX_Int(pFX, _T("MAXIMUM_SCALE"), m_nMaximumScale);
- }