DB 問合せ


  条件フィールドの追加



  
// *********************************************************
// 問合せ処理
// *********************************************************
void MyDlg::GetData()
{
	if ( !CurDb.Connect() ) {
		MsgOk("接続に失敗しました \n%s", CurDb.ErrMessage.szLboxString);
		return;
	}

	LboxString Query;

	Query.operator = ("select * from 商品分類マスタ");

	// 以下条件フィールド追加に伴う処理記述
	LboxString Cond( "" );
	LboxString Buff;

	this->EditGetText( IDC_EDIT1, &Buff );
	Buff.Trim( "  " );
	if ( Buff.operator != ( ""  ) ) {
		if ( Cond.operator == ( "" ) ) {
			Cond.operator += (" where ");
		}
		else {
			Cond.operator += (" and ");
		}
		Cond.operator += (" 名称 like ");
		Buff.Enclose( "%" );
		Buff.Enclose( "'" );
		Cond.operator += ( &Buff );
	}

	Query.operator += ( &Cond );
	// 以上条件フィールド追加に伴う処理記述

	int nRet;

	LView->Hide();
	this->StatusSetText( "" );
	nRet = CurDb.LoadSqlData( LView, 0, &Query );
	switch( nRet ) {
		case -1:
			this->StatusSetText( &(CurDb.ErrMessage) );
			break;
		case 0:
			this->StatusSetText( "対象データが存在しません" );
			break;
		default:
			this->StatusPrintf( "%d 件のデータが選択されました", nRet );
			break;
	}
	LView->Fit();
	LView->Show();

	CurDb.DisConnect();	
}
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ