⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsodbc.cpp

📁 Soul的源代码,类似于劲舞团之类的游戏
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		for( int i = 0; i < MAX_EQUIPCOUNT; i++ )
		{
			strcat( cText,",?,?,?,?,?,?,?");
		}
		strcat(cText,")}");
		SQLPrepare( m_hStmtEquipUp, (SQLCHAR *)cText, SQL_NTS );

		int icount = 1;
		SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
			&m_info.m_CharInfo._iCharIndex, sizeof(int), &m_siZero );
		icount++;
		for( i = 0; i < MAX_EQUIPCOUNT; i++ )
		{
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strEquipItem[i].ItemDate.iItemMakeTime, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strEquipItem[i].ItemSN.iItemSN, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strEquipItem[i].ItemInfo.wItemNo, sizeof(short), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strEquipItem[i].ItemInfo.byItemCount, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strEquipItem[i].ItemInfo.byItemLevel, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strEquipItem[i].ItemInfo.iItemOption.bfc_ItemOption.iItem_SpOption, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtEquipUp, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strEquipItem[i].ItemInfo.iItemOption.bfc_ItemOption.iItem_SttOption, sizeof(short), &m_siZero );
			icount++;
		}

		// Inven 
		wsprintf(cText,"{call s_UpdateInven (?");
		for( i = 0; i < MAX_INVENCOUNT; i++ )
		{
			strcat( cText,",?,?,?,?,?,?,?");
		}
		strcat(cText,")}");
		SQLPrepare( m_hStmtInvenUp, (SQLCHAR *)cText, SQL_NTS );
		icount = 1;
		SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
			&m_info.m_CharInfo._iCharIndex, sizeof(int), &m_siZero );
		icount++;
		for( i = 0; i < MAX_INVENCOUNT; i++ )
		{
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strInvenItem[i].ItemDate.iItemMakeTime, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strInvenItem[i].ItemSN.iItemSN, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strInvenItem[i].ItemInfo.wItemNo, sizeof(short), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strInvenItem[i].ItemInfo.byItemCount, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strInvenItem[i].ItemInfo.byItemLevel, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strInvenItem[i].ItemInfo.iItemOption.bfc_ItemOption.iItem_SpOption, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtInvenUp, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strInvenItem[i].ItemInfo.iItemOption.bfc_ItemOption.iItem_SttOption, sizeof(short), &m_siZero );
			icount++;
		}
		// store1
		wsprintf(cText,"{call s_UpdateStore (?");
		for( i = 0; i < HALF_STORECOUNT; i++ )
		{
			strcat( cText,",?,?,?,?,?,?,?");
		}
		strcat(cText,")}");
		SQLPrepare( m_hStmtStoreUp, (SQLCHAR *)cText, SQL_NTS );
		icount = 1;
		SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
			&m_info.m_CharInfo._iAccountID, sizeof(int), &m_siZero );
		icount++;
		for( i = 0; i < HALF_STORECOUNT; i++ )
		{
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strStoreItem[i].ItemDate.iItemMakeTime, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strStoreItem[i].ItemSN.iItemSN, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strStoreItem[i].ItemInfo.wItemNo, sizeof(short), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strStoreItem[i].ItemInfo.byItemCount, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strStoreItem[i].ItemInfo.byItemLevel, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strStoreItem[i].ItemInfo.iItemOption.bfc_ItemOption.iItem_SpOption, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStoreUp, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strStoreItem[i].ItemInfo.iItemOption.bfc_ItemOption.iItem_SttOption, sizeof(short), &m_siZero );
			icount++;
		}
		// store2
		wsprintf(cText,"{call s_UpdateStore2 (?");
		for( i = 0; i < HALF_STORECOUNT; i++ )
		{
			strcat( cText,",?,?,?,?,?,?,?");
		}
		strcat(cText,")}");
		SQLPrepare( m_hStmtStore2Up, (SQLCHAR *)cText, SQL_NTS );
		icount = 1;
		SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
			&m_info.m_CharInfo._iAccountID, sizeof(int), &m_siZero );
		icount++;
		for( i = 0; i < HALF_STORECOUNT; i++ )
		{
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemDate.iItemMakeTime, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemSN.iItemSN, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemInfo.wItemNo, sizeof(short), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemInfo.byItemCount, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, sizeof(BYTE), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemInfo.byItemLevel, sizeof(BYTE), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(int), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemInfo.iItemOption.bfc_ItemOption.iItem_SpOption, sizeof(int), &m_siZero );
			icount++;
			SQLBindParameter( m_hStmtStore2Up, icount, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_SMALLINT, sizeof(short), 0,
				&m_info.strStoreItem[i + HALF_STORECOUNT].ItemInfo.iItemOption.bfc_ItemOption.iItem_SttOption, sizeof(short), &m_siZero );
			icount++;
		}
	}
	return TRUE;
}
//-------------------------------------------------------------------------------------------------------
//	Name		 :: void CleanupConn(void)
//	Create Date	 :: 2004/10/29
//	Description	 :: 
//	param		 ::
//	Return Value :: 
//	Bug	Report	 ::
//-------------------------------------------------------------------------------------------------------
void TsODBC::CleanupConn(void)
{
	if( m_hStmtCharInfoUp)
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtCharInfoUp );
		m_hStmtCharInfoUp = NULL;
	}
	if( m_hStmtDetailInfoUp )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtDetailInfoUp );
		m_hStmtDetailInfoUp = NULL;
	}
	if( m_hStmtEquipUp )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtEquipUp );
		m_hStmtEquipUp = NULL;
	}
	if( m_hStmtInvenUp )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtInvenUp );
		m_hStmtInvenUp = NULL;
	}
	if( m_hStmtStoreUp )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtStoreUp );
		m_hStmtStoreUp = NULL;
	}
	if( m_hStmtStore2Up )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtStore2Up );
		m_hStmtStore2Up = NULL;
	}
	if( m_hStmtDelChar )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtDelChar );
		m_hStmtDelChar = NULL;
	}
	if( m_hStmtInsert )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtInsert );
		m_hStmtInsert = NULL;
	}

	if( m_hStmtCharInfoSt )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtCharInfoSt );
		m_hStmtCharInfoSt = NULL;
	}
	if( m_hStmtDetailInfoSt )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtDetailInfoSt );
		m_hStmtDetailInfoSt = NULL;
	}
	if( m_hStmtEquipSt )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtEquipSt );
		m_hStmtEquipSt = NULL;
	}
	if( m_hStmtInvenSt )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtInvenSt );
		m_hStmtInvenSt = NULL;
	}
	if( m_hStmtStoreSt )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtStoreSt );
		m_hStmtStoreSt = NULL;
	}
	if( m_hStmtStore2St )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtStore2St );
		m_hStmtStore2St = NULL;
	}

	if( m_hStmtAccountSt )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtAccountSt );
		m_hStmtAccountSt = NULL;
	}
	if( m_hStmtLogInUp )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtLogInUp );
		m_hStmtLogInUp = NULL;
	}
	if( m_hStmtLogOutUp )
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtLogOutUp );
		m_hStmtLogOutUp = NULL;
	}

	if(m_hStmtcnntpl)
	{
		SQLFreeHandle( SQL_HANDLE_STMT, m_hStmtcnntpl );
		m_hStmtcnntpl = NULL;
	}

	if(m_hDBC)
	{
		SQLDisconnect( m_hDBC );
		m_hDBC = NULL;
	}
	if(m_hDBC)
	{
		SQLFreeHandle( SQL_HANDLE_DBC, m_hDBC );
		m_hDBC = NULL;
	}
	if(m_hEnv)
	{
		SQLFreeHandle( SQL_HANDLE_ENV, m_hEnv );
		m_hEnv = NULL;
	}
}
//-------------------------------------------------------------------------------------------------------
//	Name		 :: BOOL ReconnectODBC(void)
//	Create Date	 :: 2004/10/29
//	Description	 :: 
//	param		 ::
//	Return Value :: 
//	Bug	Report	 ::
//-------------------------------------------------------------------------------------------------------
BOOL TsODBC::ReconnectODBC(void)
{
	CLock lock( &m_cs );
	m_dwLastTick = GetTickCount();

	CleanupConn();
	if( !Connection() ) return FALSE;
	return TRUE;
}
//-------------------------------------------------------------------------------------------------------
//	Name		 :: void PrintError(SQLHSTMT hstmt, SQLHDBC hDBC,int icallType)
//	Create Date	 :: 2004/10/29
//	Description	 :: 
//	param		 ::
//	Return Value :: 
//	Bug	Report	 ::
//-------------------------------------------------------------------------------------------------------
void TsODBC::PrintError(SQLHSTMT hstmt, SQLHDBC hDBC)
{
	char	cText[1024];
	int		iErrCount = 0;
	SQLSMALLINT	MsgLen;
	SQLRETURN	ret;
	SQLINTEGER	NativeError;
	SQLCHAR		sqlState[6], Msg[256];

	if( hstmt != NULL )
	{
		SQLGetDiagField( SQL_HANDLE_STMT, hstmt, 0, SQL_DIAG_NUMBER, &iErrCount, 0, &MsgLen );
		for( int i = 1; i <= iErrCount; i++ )
		{
			ret = SQLGetDiagRec( SQL_HANDLE_STMT, hstmt, i, sqlState, &NativeError, Msg, sizeof(Msg), &MsgLen );
			wsprintf( cText,"SQLSTATE:%s, NativeError:%d",	(LPCTSTR)sqlState, NativeError);
			SendMessage(m_hTextHwnd,LB_ADDSTRING,0,(LPARAM)cText);
			wsprintf( cText,"柳窜沥焊:%s",(LPCTSTR)Msg );
			SendMessage(m_hTextHwnd,LB_ADDSTRING,0,(LPARAM)cText);
		}
	}
	else
	{
		SQLGetDiagField( SQL_HANDLE_DBC, hDBC, 0, SQL_DIAG_NUMBER, &iErrCount, 0, &MsgLen );
		for( int i = 1; i <= iErrCount; i++ )
		{
			ret = SQLGetDiagRec( SQL_HANDLE_DBC, hDBC, i, sqlState, &NativeError, Msg, sizeof(Msg), &MsgLen );
			wsprintf( cText,"SQLSTATE:%s, NativeError:%d",	(LPCTSTR)sqlState, NativeError);
			SendMessage(m_hTextHwnd,LB_ADDSTRING,0,(LPARAM)cText);
			wsprintf( cText,"柳窜沥焊:%s",(LPCTSTR)Msg );
			SendMessage(m_hTextHwnd,LB_ADDSTRING,0,(LPARAM)cText);
		}
	}
	// SQLSTATE
	// 01000 老馆利牢 俊矾
	// 01004 巩磊凯狼 坷弗率捞 肋啡促. 官牢爹等 滚欺狼 辨捞啊 陋阑 锭 惯积茄促.
	// 01S02 可记蔼捞 函版登菌促.
	// 22003 箭磊蔼捞 裹困甫 逞菌促.
	// 42000 巩过 俊矾 肚绰 咀技胶 困馆
	// 42S02 抛捞喉 肚绰 轰啊 粮犁窍瘤 臼绰促.
	// HY000 老馆利牢 俊矾
	// HYC00 可记栏肺 力傍登绰 扁瓷捞 备泅登绢 乐瘤 臼促.
	// HYT00 力茄 矫埃 檬苞
}
//----------------------------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -