当前位置: 首页>>代码示例>>C++>>正文


C++ CDatabase类代码示例

本文整理汇总了C++中CDatabase的典型用法代码示例。如果您正苦于以下问题:C++ CDatabase类的具体用法?C++ CDatabase怎么用?C++ CDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnInitDialog

BOOL ManagerProperty::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	//this->GetParent()->SendMessage(WM_CLOSE);//关闭父对话框
	CDatabase db;
	db.Open("bankmanagement");
	CString sqlstr,sqlstramount;
	sqlstr.Format(_T("select manager_name from manager where manager_login_name='%s'"), CurrentUser);
	CRecordset rs(&db);
	rs.Open(CRecordset::forwardOnly, (_T("%s"), sqlstr));
	CString	name;
	rs.GetFieldValue(_T("manager_name"), name);
	GetDlgItem(IDC_MANAGER_NAME)->SetWindowTextA((CString)name);
	rs.Close();
	////////////////////////////上姓名下金额
	sqlstramount.Format(_T("select money_amount from bank_account"));
	CRecordset rss(&db);
	rss.Open(CRecordset::forwardOnly, (_T("%f"), sqlstramount));
	CString	stramount;
	rss.GetFieldValue(_T("money_amount"), stramount);
	m_ManagerPropertyamount = _tstof(stramount);
	UpdateData(FALSE);
	rss.Close();
	db.Close();


	///////////////////////////////产生图表
	CSeries0 lineSeries = (CSeries0)m_chartfinal.Series(0);
	lineSeries.Clear();

	
	sqlstr.Format(_T("CREATE OR REPLACE VIEW `view_day_property`AS SELECT * FROM day_property ORDER BY day_property.dayproperty_id DESC LIMIT 10;"));
	
	db.Open("bankmanagement");
	db.ExecuteSQL(sqlstr);
	sqlstr.Format(_T("select day_time,bank_balance from view_day_property  ORDER BY dayproperty_id ASC;"));
	CRecordset rssss(&db);
	rssss.Open(CRecordset::forwardOnly, (_T("%s"), sqlstr));
	CString strx, strbalance;
	double daybalance;


	for (int i = 0; i<10; i++)
	{

		CString varDayTime;
		rssss.GetFieldValue(_T("day_time"), varDayTime);
		strx.Format(_T("%s"), varDayTime);

		CString varBankBalance;
		rssss.GetFieldValue(_T("bank_balance"), varBankBalance);
		strbalance.Format(_T("%s"), varBankBalance);
		daybalance = _ttof(strbalance);

		lineSeries.AddXY((double)i, daybalance, strx, 0);
		rssss.MoveNext();
	}

	rssss.Close();


	db.Close();


	return true;
}
开发者ID:ShipuW,项目名称:ebank-MFC,代码行数:66,代码来源:ManagerProperty.cpp

示例2: RINOK

HRESULT CInArchive::Open2(IInStream *stream,
    const UInt64 *searchHeaderSizeLimit,
    CDatabase &database)
{
  database.Clear();
  RINOK(stream->Seek(0, STREAM_SEEK_SET, &database.StartPosition));

  RINOK(FindSignatureInStream(stream, NHeader::kMarker, NHeader::kMarkerSize,
      searchHeaderSizeLimit, database.StartPosition));

  RINOK(stream->Seek(database.StartPosition + NHeader::kMarkerSize, STREAM_SEEK_SET, NULL));
  if (!inBuffer.Create(1 << 17))
    return E_OUTOFMEMORY;
  inBuffer.SetStream(stream);
  inBuffer.Init();

  CInArchiveInfo &ai = database.ArchiveInfo;

  ai.Size = ReadUInt32();
  if (ReadUInt32() != 0)
    return S_FALSE;
  ai.FileHeadersOffset = ReadUInt32();
  if (ReadUInt32() != 0)
    return S_FALSE;

  ai.VersionMinor = ReadByte();
  ai.VersionMajor = ReadByte();
  ai.NumFolders = ReadUInt16();
  ai.NumFiles = ReadUInt16();
  ai.Flags = ReadUInt16();
  if (ai.Flags > 7)
    return S_FALSE;
  ai.SetID = ReadUInt16();
  ai.CabinetNumber = ReadUInt16();

  if (ai.ReserveBlockPresent())
  {
    ai.PerCabinetAreaSize = ReadUInt16();
    ai.PerFolderAreaSize = ReadByte();
    ai.PerDataBlockAreaSize = ReadByte();

    Skip(ai.PerCabinetAreaSize);
  }

  {
    if (ai.IsTherePrev())
      ReadOtherArchive(ai.PreviousArchive);
    if (ai.IsThereNext())
      ReadOtherArchive(ai.NextArchive);
  }
  
  int i;
  for (i = 0; i < ai.NumFolders; i++)
  {
    CFolder folder;

    folder.DataStart = ReadUInt32();
    folder.NumDataBlocks = ReadUInt16();
    folder.CompressionTypeMajor = ReadByte();
    folder.CompressionTypeMinor = ReadByte();

    Skip(ai.PerFolderAreaSize);
    database.Folders.Add(folder);
  }
  
  RINOK(stream->Seek(database.StartPosition + ai.FileHeadersOffset, STREAM_SEEK_SET, NULL));

  inBuffer.SetStream(stream);
  inBuffer.Init();
  for (i = 0; i < ai.NumFiles; i++)
  {
    CItem item;
    item.Size = ReadUInt32();
    item.Offset = ReadUInt32();
    item.FolderIndex = ReadUInt16();
    UInt16 pureDate = ReadUInt16();
    UInt16 pureTime = ReadUInt16();
    item.Time = ((UInt32(pureDate) << 16)) | pureTime;
    item.Attributes = ReadUInt16();
    item.Name = SafeReadName();
    int folderIndex = item.GetFolderIndex(database.Folders.Size());
    if (folderIndex >= database.Folders.Size())
      return S_FALSE;
    database.Items.Add(item);
  }
  return S_OK;
}
开发者ID:KDE,项目名称:necessitas-installer-framework,代码行数:87,代码来源:CabIn.cpp

示例3: ModifyStyleEx

BOOL AccountDetail::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	ModifyStyleEx(0, WS_EX_APPWINDOW);
	HICON m_hIcon;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标
	
	AccountOperate.InsertColumn(1, _T("操作类型"), LVCFMT_LEFT, 200);
	AccountOperate.InsertColumn(2, _T("金额"), LVCFMT_LEFT, 80);
	AccountOperate.InsertColumn(3, _T("时间"), LVCFMT_LEFT, 80);
	
	
	CString sqlstr;
	sqlstr.Format(_T("select money_value,operate_time from operate_deposit where card_number ='%s'"), CardDetail);
	AccountOperate.DeleteAllItems();

	CDatabase db;
	db.Open("bankmanagement");
	CRecordset rs(&db);
	rs.Open(CRecordset::forwardOnly, (_T("%s"), sqlstr));
	while (!rs.IsEOF())
	{
		CString varOperateType;
		varOperateType = "存款";
		AccountOperate.InsertItem(0, varOperateType);
		CString varOperateAmount;
		rs.GetFieldValue(_T("money_value"), varOperateAmount);
		AccountOperate.SetItemText(0, 1, varOperateAmount);
		CString varOperateTime;
		rs.GetFieldValue(_T("operate_time"), varOperateTime);
		AccountOperate.SetItemText(0, 2, varOperateTime);
		rs.MoveNext();
	}
	rs.Close();
	AccountOperate.SetExtendedStyle(LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
	//////////////////////////////////////////////////上面是list control内容,下面是编辑框内容
	
	
	CString sqlstrinfo;
	m_DetailCard = CardDetail;
	sqlstrinfo.Format(_T("select register_time,money_balance,card_type from card where card_number='%s'"),m_DetailCard);
	CRecordset rss(&db);
	rss.Open(CRecordset::forwardOnly, (_T("%s"), sqlstrinfo));
	
	while (!rss.IsEOF())
	{
		
		rss.GetFieldValue(_T("register_time"), m_DetailTime);
		
		rss.GetFieldValue(_T("money_balance"), m_DetailBalance);
		
		rss.GetFieldValue(_T("card_type"), m_DetailType);
		rss.MoveNext();
	}
	UpdateData(false);



	rss.Close();
	db.Close();
	return true;
}
开发者ID:ShipuW,项目名称:ebank-MFC,代码行数:65,代码来源:AccountDetail.cpp

示例4: GetWhereClause

CStdString CSmartPlaylistRule::GetWhereClause(CDatabase &db, const CStdString& strType) const
{
  SEARCH_OPERATOR op = m_operator;
  if ((strType == "tvshows" || strType == "episodes") && m_field == FieldYear)
  { // special case for premiered which is a date rather than a year
    // TODO: SMARTPLAYLISTS do we really need this, or should we just make this field the premiered date and request a date?
    if (op == OPERATOR_EQUALS)
      op = OPERATOR_CONTAINS;
    else if (op == OPERATOR_DOES_NOT_EQUAL)
      op = OPERATOR_DOES_NOT_CONTAIN;
  }

  CStdString operatorString, negate;
  if (GetFieldType(m_field) == TEXTIN_FIELD)
  {
    if (op == OPERATOR_DOES_NOT_EQUAL)
      negate = " NOT";
  }
  else
  {
    // the comparison piece
    switch (op)
    {
    case OPERATOR_CONTAINS:
      operatorString = " LIKE '%%%s%%'"; break;
    case OPERATOR_DOES_NOT_CONTAIN:
      negate = " NOT"; operatorString = " LIKE '%%%s%%'"; break;
    case OPERATOR_EQUALS:
      operatorString = " LIKE '%s'"; break;
    case OPERATOR_DOES_NOT_EQUAL:
      negate = " NOT"; operatorString = " LIKE '%s'"; break;
    case OPERATOR_STARTS_WITH:
      operatorString = " LIKE '%s%%'"; break;
    case OPERATOR_ENDS_WITH:
      operatorString = " LIKE '%%%s'"; break;
    case OPERATOR_AFTER:
    case OPERATOR_GREATER_THAN:
    case OPERATOR_IN_THE_LAST:
      operatorString = " > '%s'"; break;
    case OPERATOR_BEFORE:
    case OPERATOR_LESS_THAN:
    case OPERATOR_NOT_IN_THE_LAST:
      operatorString = " < '%s'"; break;
    case OPERATOR_TRUE:
      operatorString = " = 1"; break;
    case OPERATOR_FALSE:
      negate = " NOT "; operatorString = " = 0"; break;
    default:
      break;
    }
  }

  // FieldInProgress does not have any values in m_parameter, it works on the operator
  if (m_field == FieldInProgress && (strType == "movies" || strType == "episodes"))
    return "idFile " + negate + " in (select idFile from bookmark where type = 1)";

  // now the query parameter
  CStdString wholeQuery;
  for (vector<CStdString>::const_iterator it = m_parameter.begin(); it != m_parameter.end(); /* it++ is done further down */)
  {
    CStdString parameter;
    if (GetFieldType(m_field) == TEXTIN_FIELD)
    {
      CStdStringArray split;
      StringUtils::SplitString(*it, ",", split);
      for (CStdStringArray::iterator itIn = split.begin(); itIn != split.end(); ++itIn)
      {
        if (!parameter.IsEmpty())
          parameter += ",";
        parameter += db.PrepareSQL("'%s'", (*itIn).Trim().c_str());
      }
      parameter = " IN (" + parameter + ")";
    }
    else
      parameter = db.PrepareSQL(operatorString.c_str(), it->c_str());

    if (GetFieldType(m_field) == DATE_FIELD)
    {
      if (m_operator == OPERATOR_IN_THE_LAST || m_operator == OPERATOR_NOT_IN_THE_LAST)
      { // translate time period
        CDateTime date=CDateTime::GetCurrentDateTime();
        CDateTimeSpan span;
        span.SetFromPeriod(*it);
        date-=span;
        parameter = db.PrepareSQL(operatorString.c_str(), date.GetAsDBDate().c_str());
      }
    }
    else if (m_field == FieldTime)
    { // translate time to seconds
      CStdString seconds; seconds.Format("%i", StringUtils::TimeStringToSeconds(*it));
      parameter = db.PrepareSQL(operatorString.c_str(), seconds.c_str());
    }

    CStdString query;
    CStdString table;
    if (strType == "songs")
    {
      table = "songview";

      if (m_field == FieldGenre)
//.........这里部分代码省略.........
开发者ID:mindcorrosive,项目名称:xbmc,代码行数:101,代码来源:SmartPlayList.cpp

示例5: ShellExecute

void CTrainDlg::OnBnClickedTraining()
{
	// TODO: 在此添加控件通知处理程序代码
	CString exePath = "..\\haartraining\\Debug\\haartraining.exe";

	CString value;

	m_iSplits = 2;
	m_iStages = 4;

	value.Format("-data %s -vec %s -bg %s -npos %d -nneg %d -nsplits %d -nstages %d  -nonsym -mem 512 -w %d -h %d -mode all",
		m_data,m_vec,m_bg,m_iPositiveNum,m_iNegetiveNum,m_iSplits,m_iStages,m_iImgWidth,m_iImgHeight);
	ShellExecute((HWND)AfxGetMainWnd(),"open",exePath,value,NULL,SW_SHOW );
 
	CFileFind filefinder;
 
	CString SourcePath;
	//SourcePath.Format("E:\\训练分类器\\result.xml");
	SourcePath.Format("%s\\result.xml",m_data.Mid(0,m_positive.ReverseFind('\\')));
 
	CString filename;
 
	BOOL bfind = filefinder.FindFile(SourcePath);
 
	CString DisPath;
 
	if (bfind)
 
	{
 
	   bfind = filefinder.FindNextFile();
 
	   //filename = filefinder.GetFileName();
 
	   DisPath = "..\\classifier\\result.xml";
 
	   CopyFile(SourcePath,DisPath,1);

	    CDatabase db;

		 db.Open(NULL, FALSE, FALSE, _T("ODBC;DSN=face;UID=root;PWD=root"));
		 CString name, path, desc,str;
		 name = "result.xml";
		 path = "classifier\\\\result.xml";
		 desc = "训练分类器";

		 if(name == "" || path == "" || desc == "")
		 {
			 MessageBox("所有属性不能为空");
			 db.Close();
			 return;
		 }
	 
		 //判断该目录下分类器是否存在
		 CFileFind finder;
		 if( !finder.FindFile("..\\"+path))
		 {
			 MessageBox("该分类器不存在");
			 db.Close();
			 return;
		 }

		 str.Format("insert into classifier(cname,cpath,cdescribe)  values('%s','%s','%s')", name, path, desc);
		 db.ExecuteSQL(str);
		 db.Close();
		 MessageBox("添加成功");
 
	}
 
	filefinder.Close();

}
开发者ID:ywydigital,项目名称:FaceDetection,代码行数:72,代码来源:TrainDlg.cpp

示例6: _T

UINT CNav_ExportCustomsDlg::ExportData(LPVOID p)
{
	
	HRESULT hRes;
	Excel::_ApplicationPtr appExcel;
	hRes = appExcel.CreateInstance( _T("Excel.Application"));

	CNav_ExportCustomsDlg *Dialog;
	Dialog = (CNav_ExportCustomsDlg*)p;

	if(Dialog != NULL)
	{
		

		CString sStart, sEnd;
		Dialog->m_EndDate.GetWindowText(sEnd);
		Dialog->m_StartDate.GetWindowText(sStart);

		CString sGTD;
		Dialog->m_EdGTDNUMBER.GetWindowText(sGTD);
		COleDateTime datStart,datEnd, cDate;
		datStart.ParseDateTime(sStart);
		datEnd.ParseDateTime(sEnd);
	
		CString sConnect;
		CString sServer, sDatabase;
		sServer = sReadFromIni(_T("DB"),_T("SERVER"),_T("svbyminssq3"));
		//sWriteToIni(_T("DB"),_T("SERVER"),sServer);
		sDatabase = sReadFromIni(_T("DB"),_T("DATABASE"),_T("SHATE-M-8"));
		//sWriteToIni(_T("DB"),_T("DATABASE"),sDatabase);


		
		Excel::WorkbooksPtr ExcelBooks;
		Excel::_WorkbookPtr ExcelBook;
		Excel::_WorksheetPtr ExcelSheet;
		Excel::RangePtr range;

		
		
		

		VARIANT bTRUE;
		bTRUE.vt = 11;
		bTRUE.boolVal = TRUE;
		appExcel->Visible[0] = FALSE;
		ExcelBook= appExcel->Workbooks->Add();
		ExcelSheet = ExcelBook->Worksheets->Item[1];

		sConnect.Format(_T("DRIVER=SQL Server;SERVER=%s;UID=;WSID=%s;Trusted_Connection=Yes;DATABASE=%s;LANGUAGE=русский"),sServer,GetWinUserName(),sDatabase);
		CDatabase* dBase;
		dBase = NULL;
		try
		{
			dBase = new(CDatabase);
			dBase->SetQueryTimeout(600);
			dBase->OpenEx(sConnect,CDatabase::noOdbcDialog);
			sConnect.Format(_T("EXEC [sp_setapprole] '%s', '%s', 'none', 0, 0"),_T("$ndo$shadow"),_T("FF5EC4E40F67BD4EDF3D04F8B84364DAD0")); 
			dBase->ExecuteSQL(sConnect);
		}
		catch(CDBException *exsept)
		{
			appExcel->Visible[0] = TRUE;
			Dialog->m_stState.SetWindowTextW(exsept->m_strError);
			exsept->Delete();
			if(dBase != NULL)
			{
				if(dBase->IsOpen())
				{
					dBase->Close();
				}
				delete(dBase);
			}
			dBase = NULL;
			Dialog->m_BtOK.ShowWindow(1);
			Dialog->SecondThread = NULL;
			return 0;
		}
		CString sSQL;
		try
		{
			

			CRecordset Query(dBase);
		
			int iField;
			CDBVariant dbValue;
			Dialog->m_stState.SetWindowTextW(_T("Формирование"));
			sGTD = sGTD + _T("'");
			sSQL = _T("select distinct SIH.[Posting Date],(SIL.[TTN Series]+SIL.[TTN Number]) AS TTN,SIL.[Item No_ 2], SIH.[Bill-to Name] ");
			sSQL = sSQL + _T(" from [")+sDatabase;
			sSQL = sSQL + _T("$Sales Invoice Header] as SIH join [");
			sSQL = sSQL + sDatabase;
			sSQL = sSQL + _T("$Sales Invoice Line] as SIL on SIL.[Document No_] = SIH.[No_] and SIL.[No_] is not null and SIL.[No_] <> ''  and SIL.[TTN Series] <> '' and SIL.[TTN Number] <> '' join [");
			sSQL = sSQL + sDatabase;
			sSQL = sSQL + _T("$Custom Declaration Relation] as CDR on CDR.[Item No_] = SIL.[No_] and CDR.[Document Type] = 5 and CDR.[CD No_] = '") + sGTD;
			sSQL = sSQL + _T(" where [Sales Process Type Code] = 'Б/Н_ДОСТАВКА' and Left(CONVERT ( nchar , SIH.[Posting Date], 112),8) >= '")+ datStart.Format(_T("%Y%m%d"))+_T("'");
			sSQL = sSQL + _T(" and Left(CONVERT ( nchar , SIH.[Posting Date], 112),8) <= '")+ datEnd.Format(_T("%Y%m%d"))+_T("'");
			//sSQL = sSQL + _T(" and CDR.[CD No_] = '") + sGTD;

//.........这里部分代码省略.........
开发者ID:BeL1kOFF,项目名称:SHATE,代码行数:101,代码来源:Nav_ExportCustomsDlg.cpp

示例7: ShowMessage

BOOL CEdRptExport::ExportDBData(ofstream &htm, ofstream &txt)
{
	CDatabase db;
	BOOL bRet = FALSE;

	CString csHeadFile = m_pDoc->m_szHeadRight;
	if (m_pDoc->m_szODBCLink.IsEmpty())
	{
		ShowMessage(m_pDoc->GetHWnd(), "没有给定数据库指针,也没有指定链接字!");
		return FALSE;
	}

	if (!db.OpenEx(m_pDoc->m_szODBCLink, CDatabase::openReadOnly | CDatabase::noOdbcDialog))
	{
		ShowMessage(m_pDoc->GetHWnd(), "无法打开数据库连接 %s", m_pDoc->m_szODBCLink);
		return FALSE;
	}

	try 
	{
		UINT nRecCount = m_pDoc->GetRecordCount(db);

		CString szSQL = m_pDoc->m_szSQL;
		if (nRecCount > (int)m_pDoc->m_nMaxRecordNum)
		{
			CString str;
			str.Format(_T("共有 %d 条记录,但模版设计最大记录数为 %d,\n是否只 %d 条记录?\n"
				"注意:如何选否,会给数据库很大压力,甚至取消操作!"), 
				nRecCount, m_pDoc->m_nMaxRecordNum, m_pDoc->m_nMaxRecordNum);
			
			UINT ulSelect = IDNO;
			if (m_pDoc->GetHWnd())
				ulSelect = MessageBox(m_pDoc->GetHWnd(), str, _T("EdFc"), MB_YESNOCANCEL);
			
			if (ulSelect == IDNO)
				;
			else if (ulSelect == IDCANCEL)
				return FALSE;
			else // IDYES
			{
				csHeadFile.Format(_T("  %d条记录未导出"), nRecCount - m_pDoc->m_nMaxRecordNum);
				nRecCount = m_pDoc->m_nMaxRecordNum;
				
				CString csDBDrv = getDBDriver(m_pDoc->m_szODBCLink);
				csDBDrv.MakeLower();
				if (csDBDrv.Find("oracle") >= 0)
				{
					CString szTmp = szSQL;
					szTmp.MakeLower();
					int nFind = szTmp.Find(" where ");
					if (nFind > 0)
					{
						szTmp.Format(" ROWNUM <= %d AND ", m_pDoc->m_nMaxRecordNum);
						szSQL.Insert(nFind + (int)_tcslen(" where "), (LPCSTR)szTmp);
					}
					else
					{
						szTmp.Format(" WHERE ROWNUM <= %d ", m_pDoc->m_nMaxRecordNum);
						szSQL += szTmp;
					}
				}
				else if (csDBDrv.Find("mysql") >= 0)
				{
					CString szTmp;
					szTmp.Format(" Limit 0, %d ", m_pDoc->m_nMaxRecordNum);
					szSQL += szTmp;
				}
// 				else if (csDBDrv.IsEmpty())
// 					ShowMessage(m_pDoc->GetHWnd(), "报表打印组件无法判断该数据库的类型。");
				else
				{
					CString str;
					str.Format(_T("[ %s ] 数据库无法使用修改SQL的方法限制记录个数,而打开大数据集可能会出现异常\n,是否先修改查询条件,再进行打印?"), csDBDrv);
					if (m_pDoc->GetHWnd() && MessageBox(m_pDoc->GetHWnd(), str,_T("BSRpter"), MB_YESNO) == IDYES)
						return FALSE;
				}
			}
		}
		
		CRecordset rc(&db);
		rc.Open(CRecordset::forwardOnly, szSQL);
		UINT nFieldCount = rc.GetODBCFieldCount();
		
		CString szTitle = m_pDoc->m_szTitle;
		TxtToHtml(szTitle);

		CString szHeadRight = m_pDoc->m_szHeadRight;
		TxtToHtml(szHeadRight);
		htm << "<html><head><title>" 
			<< (LPCTSTR)szTitle 
			<< "</title></head>"
			<< endl;

		htm << "<body>" << endl
			<< "<table width=100%>" << endl
			<< "<tr>" << endl
			<< "\t<td width=20%>&nbsp;</td>" << endl
			<< "\t<td width=60% align=center><font size=+3>" 
			<< (LPCTSTR)szTitle
			<< "</font></td>" << endl
//.........这里部分代码省略.........
开发者ID:zphseu,项目名称:cuiyan,代码行数:101,代码来源:EdRptExport.cpp

示例8: ASSERT

BOOL CLDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	 m_hYellowBrush=(HBRUSH)GetStockObject(BLACK_BRUSH);

	 m_hRedBrush=(HBRUSH)GetStockObject(BLACK_BRUSH);


	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	
///////////////////////// initializations ///////////////////////////////////

pt1[0].x=0;
pt1[0].y=0;
pt2[0].x=1;
pt2[0].y=1; 
pt1[1].x=0;
pt1[1].y=3;
pt2[1].x=0;
pt2[1].y=3; 
pt1[2].x=8;
pt1[2].y=7;
pt2[2].x=9;
pt2[2].y=9; 
pt1[3].x=8;
pt1[3].y=5;
pt2[3].x=9;
pt2[3].y=6; 
pt1[4].x=4;
pt1[4].y=4;
pt2[4].x=5;
pt2[4].y=5; 

cmpt[0].x=0;
cmpt[0].y=0;
cmpt[1].x=0;
cmpt[1].y=4;
cmpt[2].x=5;
cmpt[2].y=5;
cmpt[3].x=5;
cmpt[3].y=7;
cmpt[4].x=8;
cmpt[4].y=8;

///////////////////////// initializations ///////////////////////////////////



///////////////////////////////database read from floortab/////////////////////////////////////////////
    CDatabase xx;

	xx.Open("ODBC;DSN=geoinfo");
	CRecordset dbSQL(&xx);
	dbSQL.Open(CRecordset::forwardOnly,"select * from floortab");
	cnt=0;
	while(!dbSQL.IsEOF()) 
	{
	CString xy;
	dbSQL.GetFieldValue("fid",xy);
	flid[cnt]=atoi(xy);
	dbSQL.GetFieldValue("frows",xy);
	flrows[cnt]=atoi(xy);
	dbSQL.GetFieldValue("fclmns",xy);
	flclmns[cnt++]=atoi(xy);
	dbSQL.MoveNext();	
	}

///////////////////////////////database read from floortab//////////////////////////////////////////////

///////////////////////////////database read from labtab//////////////////////////////////////////////
	CRecordset dblab(&xx);
	dblab.Open(CRecordset::forwardOnly,"select * from labtab");
	labcount=0;
	while(!dblab.IsEOF()) 
	{
	CString xy;
//.........这里部分代码省略.........
开发者ID:akreddysoft,项目名称:CollegeCode,代码行数:101,代码来源:LDlg1.cpp

示例9: ShowMessage

BOOL CEdRptDoc::GetDataFromDB()
{
	CDatabase db;
	BOOL bRet = FALSE;
	try 
	{
		if (m_szODBCLink.IsEmpty())
		{
			ShowMessage(m_hWnd, "没有给定数据库指针,也没有指定链接字!");
			return FALSE;
		}

		if (!db.OpenEx(m_szODBCLink, CDatabase::openReadOnly | CDatabase::noOdbcDialog))
		{
			ShowMessage(m_hWnd, "无法打开数据库连接 %s", m_szODBCLink);
			return FALSE;
		}

		m_nRecCount = GetRecordCount(db);
		CRecordset rc(&db);
		
		CString szSQL = m_szSQL;
		CString csHeadRight = m_szHeadRight;
		if (m_nRecCount > (int)m_nMaxRecordNum)
		{
			CString str;
			str.Format(_T("共有 %d 条记录,但模版设计最大记录数为 %d,\n是否只 %d 条记录?\n"
				"注意:如何选否,会给数据库很大压力,甚至取消操作!"), 
				m_nRecCount, m_nMaxRecordNum, m_nMaxRecordNum);
			
			UINT ulSelect = IDNO;
			if (m_hWnd)
				ulSelect = MessageBox(m_hWnd, str, _T("BSRpter"), MB_YESNOCANCEL);

			if (ulSelect == IDNO)
				;
			else if (ulSelect == IDCANCEL)
				return FALSE;
			else // IDYES
			{
				csHeadRight.Format(_T("  %d条记录未打印"), m_nRecCount - m_nMaxRecordNum);
				m_nRecCount = m_nMaxRecordNum;
				
				CString csDBDrv = getDBDriver(m_szODBCLink);
				csDBDrv.MakeLower();
				if (csDBDrv.Find("oracle") >= 0)
				{
					CString szTmp = szSQL;
					szTmp.MakeLower();
					int nFind = szTmp.Find(" where ");
					if (nFind > 0)
					{
						szTmp.Format("ROWNUM <= %d AND ", m_nMaxRecordNum);
						szSQL.Insert(nFind + (int)_tcslen(" where "), (LPCSTR)szTmp);
					}
					else
					{
						szTmp.Format(" WHERE ROWNUM <= %d ", m_nMaxRecordNum);
						szSQL += szTmp;
					}
				}
				else if (csDBDrv.Find("mysql") >= 0)
				{
					CString szTmp;
					szTmp.Format(" Limit 0, %d ", m_nMaxRecordNum);
					szSQL += szTmp;
				}
				else
				{
					CString str;
					str.Format(_T("[ %s ] 数据库无法使用修改SQL的方法限制记录个数,"
						"而打开大数据集可能会出现异常\n,是否先修改查询条件,再进行打印?")
						, csDBDrv);
					if (m_hWnd != NULL && MessageBox(m_hWnd, str,_T("EdFc"), MB_YESNO) == IDYES)
						return FALSE;
				}
			}
		}

		rc.Open(CRecordset::forwardOnly, szSQL);
		m_nFieldCount = rc.GetODBCFieldCount();
		
		while (m_ColFmt.GetSize() > m_nFieldCount && m_nFieldCount > 1)
			m_ColFmt.RemoveAt(m_ColFmt.GetSize() - 1);
		
		COLFMT cf;
		while (m_ColFmt.GetSize() < m_nFieldCount)
			m_ColFmt.Add(cf);
				
		m_Grid.DeleteAllItems();
		int nRowCount = m_nRecCount + (m_bFootSum ? 2 : 1);
		m_Grid.SetRowCount(nRowCount);
		m_Grid.SetColumnCount(m_nFieldCount);
		
		// set ColumName;
		GV_ITEM Item;
		Item.mask = GVIF_TEXT|GVIF_FORMAT;	
		Item.row = 0;
		Item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX;
		for (Item.col = 0; Item.col < m_nFieldCount; Item.col++)
//.........这里部分代码省略.........
开发者ID:zphseu,项目名称:cuiyan,代码行数:101,代码来源:EdRptDoc.cpp

示例10: Close

/***************************************************
CUGODBCDatasource::Browse : call this function to invoke the
ODBC driver to prompt for connection params.

    This function gathers information about all of the  
    tables in the datasource selected, storing the information
    in the array m_dsInfoArray for later retrieval.  

    This function also saves the resulting connect string for
    later use.  

****************************************************/
int CUGODBCDatasource::Browse(HWND hwnd){


	HENV henv;
	HDBC hdbc;
	HSTMT hstmt;
	RETCODE retcode;
	SQLTCHAR  buf[255];

	SQLTCHAR  sqlerror[255];
	SQLTCHAR  sqlstate[255];
	SDWORD nerr, cbVal;
	SWORD num;

	// for table info....
	SQLTCHAR	szTableQualifier[128];
	SQLTCHAR	szTableOwner[128];
	SQLTCHAR	szTableName[128];
	SQLTCHAR	szTableType[128];
	SQLTCHAR	szRemarks[255];

	// close open db
	Close();
	
	// clean up previous data
	m_connectString = "";

	m_tableCount = 0;


	
	retcode = SQLAllocEnv(&henv);              // Environment handle 

	if (retcode == SQL_ERROR) {
		AfxMessageBox(_T("Probable memory allocation error in SQLAllocEnv"));
		return (int) retcode;
	}


	retcode = SQLAllocConnect(henv,&hdbc);

	if (retcode == SQL_ERROR) {
		ReportSQLError(henv, SQL_NULL_HDBC, SQL_NULL_HSTMT, retcode, _T("SQLAllocConnect"));
		SQLFreeEnv(henv);
		return (int) retcode;
	}		

	if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {

		// Set login timeout to 5 seconds. 
		 SQLSetConnectOption(hdbc, SQL_LOGIN_TIMEOUT, 5);
		// Connect to data source 
        // this should cause the ODBC Driver to come up with the
		// necessary prompts to form a connect string...
		retcode = SQLDriverConnect(hdbc,hwnd,(SQLTCHAR*)_T(""),
							0,buf,254,&num,SQL_DRIVER_PROMPT);

							
		if (retcode != SQL_SUCCESS) {
			#ifdef UG_REPORT_ERROR
				ReportSQLError(henv, hdbc, SQL_NULL_HSTMT, retcode, _T("SQLDriverConnect"));
			#endif
			// user probably cancelled connection...
                if (retcode != SQL_SUCCESS_WITH_INFO) {
    			SQLFreeConnect(hdbc);
    			SQLFreeEnv(henv);
				return retcode;
                }
		}

			

		if(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){
			// retcode from SQLDriverConnect...
			// should be cool to try to open a recordset with the info 
			// we have here in buf...
			CDatabase db;
			TCHAR buf2[255];
			UGStr::stprintf(buf2,255,_T("ODBC;%s"),buf);

            // now we have the connect string in buf2 - but wait to
            // see if we can actually open the db before storing 
            // it in m_connectString...

			try {
				retcode = db.Open(NULL,FALSE,FALSE,buf2);
			}		
			catch(CMemoryException* e){
//.........这里部分代码省略.........
开发者ID:redame,项目名称:Trading,代码行数:101,代码来源:UGODBC.CPP

示例11: PDS_DEBUG

/*
 * Adapt database to new description
 * \param description is the latest xml description of the database
 * \returns true is adaptation succeded
 */
CDatabase*	CDatabase::adapt(const string& description)
{
	PDS_DEBUG("adapt()");

	if (!initialised())
	{
		PDS_WARNING("adapt(): failed, database not initialised");
		return NULL;
	}

	// get 'From' HashKey
	CHashKey	hash1 = _Description.getHashKey();
	// get 'Into' HashKey
	CHashKey	hash2 = getSHA1((const uint8*)(description.c_str()), (uint32)description.size());

	// same hash, ok go on
	if (hash1 == hash2)
		return this;

	// build a clean reference if needed
	if (!isReferenceUpToDate())
	{
		if (!buildReference())
		{
			PDS_WARNING("adapt(): failed to buildReference()");
			return false;
		}
	}

	// backup old reference
	if (!_Reference.save(_Reference.getPath()+"ref"))
	{
		PDS_WARNING("adapt(): failed to backup reference index");
	}

	// create a new destination database
	CDatabase*	into = new CDatabase(_State.Id);

	if (!into->createFromScratch(description))
	{
		PDS_WARNING("adapt(): failed to create new reference");
		delete into;
		return NULL;
	}

	CDatabaseAdapter	adapter;

	if (!adapter.build(this, into))
	{
		PDS_WARNING("adapt(): failed to build() adapter");
		delete into;
		return NULL;
	}

	if (!adapter.buildContent())
	{
		PDS_WARNING("adapt(): adapter failed to buildContent()");
		delete into;
		return NULL;
	}

	// rebuild volatile data
	// that is all non persistant data that can be found from persistant data
	if (!into->rebuildVolatileData())
	{
		PDS_WARNING("adapt(): failed to rebuildVolatileData()");
		delete into;
		return NULL;
	}

	// init timestamps as database is ready to run
	into->initTimestamps();

	return into;
}
开发者ID:,项目名称:,代码行数:80,代码来源:

示例12: H_AUTO

/*
 * Update manager
 */
bool	CDbManager::update()
{
	H_AUTO(PDS_DbManager_update);

	CHECK_DB_MGR_INIT(update, false);

	// update stamp
	CTableBuffer::updateCommonStamp();

	TDatabaseMap::iterator	it;

	CDatabase::checkUpdateRates();


	// check evently if database need to write some delta
	TTime	tm = CTime::getLocalTime();
	if (tm >= _NextTimeDelta)
	{

		CTimestamp	starttime = _LastUpdateTime;
		CTimestamp	endtime;
		endtime.setToCurrent();

		std::vector<uint32>	ack;

		for (it=_DatabaseMap.begin(); it!=_DatabaseMap.end(); ++it)
		{
			CDatabase*	database = (*it).second;

			// generate deltas
			if (!database->buildDelta(starttime, endtime))
				nlwarning("failed to build delta for database '%d' '%s'", (*it).first, database->getName().c_str());

			// obsolete? since RBS build references and tells PDS of success/failure
			database->checkReferenceChange();

			// acknowledge last updates
			database->flushUpdates(ack);

			if (!ack.empty() && database->getMappedService().get() != 0xffff)
			{
				CMessage	msgack("PD_ACK_UPD");
				uint32		databaseId = (*it).first;
				msgack.serial(databaseId);
				msgack.serialCont(ack);
				CUnifiedNetwork::getInstance()->send(database->getMappedService(), msgack);
			}
		}

		_NextTimeDelta = tm - (tm%(DeltaUpdateRate*1000)) + (DeltaUpdateRate*1000);

		_LastUpdateTime = endtime;
	}

	CTimestamp	ts;
	ts.setToCurrent();

	// check databases require some delta packing/reference generation
	for (it=_DatabaseMap.begin(); it!=_DatabaseMap.end(); ++it)
	{
		CDatabase*	database = (*it).second;
		database->sendBuildCommands(ts);
	}

	// send messages to RBS if ready
	while (_RBSUp && !_RBSMessages.empty())
	{
		CUnifiedNetwork::getInstance()->send("RBS", *(_RBSMessages.front()));
		delete _RBSMessages.front();
		_RBSMessages.pop_front();
	}

	return true;
}
开发者ID:,项目名称:,代码行数:77,代码来源:

示例13: ReadProps

bool COleDBConnectionProp::ReadProps(CDatabase& database)
{
	return ReadProps(database.GetConnect());
}
开发者ID:malpharo,项目名称:AiPI,代码行数:4,代码来源:OleDBConnectionProp.cpp

示例14: OpenXLS

BOOL CFoulerDoc::OpenXLS(CString sFile)
{
	int i;
	double dData;
	CDatabase db;
	CString sSql;
	CString sItem;
	CString sDsn;
	CODBCFieldInfo fieldinfo;
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
	if( pFrame->m_strExcelDriver.IsEmpty() ) return FALSE;
	sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",pFrame->m_strExcelDriver,sFile);
	TRY
	{
		db.Open(NULL,FALSE,TRUE,sDsn);// Open the db using the former created pseudo DSN
		CRecordset rs( &db );// Allocate the recordset
		sSql = "SELECT * FROM Data";// Build the SQL string
		rs.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);// Execute that query (implicitly by opening the recordset)
		CFieldSelect dlg(&rs);
		if( dlg.DoModal() == IDCANCEL )
		{
			rs.Close();
			db.Close();
			return FALSE;
		}
		BeginWaitCursor();
		while( !rs.IsEOF() ) rs.MoveNext();
		int iRecCount = (int)(rs.GetRecordCount());
		rs.Close();
		rs.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);

		CProgressBar* pBar = new CProgressBar();
		ClearData();
		InsertData( iRecCount );
		for( i=0 ; i<iRecCount ; i++ )
		{
			rs.GetFieldValue(dlg.m_sField0,sItem);
			dData = atof(sItem)+dlg.m_dCo0;
			if( dlg.m_sField1 >= 0 && dlg.m_dCo1 != 0)
			{
				rs.GetFieldValue(dlg.m_sField1,sItem);
				dData += atof(sItem)*dlg.m_dCo1;
			}
			if( dlg.m_sField2 >= 0 && dlg.m_dCo2 != 0)
			{
				rs.GetFieldValue(dlg.m_sField2,sItem);
				dData += atof(sItem)*dlg.m_dCo2;
			}
			if( dlg.m_sField3 >= 0 && dlg.m_dCo3 != 0)
			{
				rs.GetFieldValue(dlg.m_sField3,sItem);
				dData += atof(sItem)*dlg.m_dCo3;
			}
			
			m_pOrgData[i]->SetItem( dData );
			m_iSubGroupIndex++;
			if( m_iSubGroupIndex >= m_iSubGroupSize )
			{
				m_iSubGroupIndex = 0;
				dData = 0;
				for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ )
				{
					dData += m_pOrgData[j]->GetItem();
				}
				m_pData[i/m_iSubGroupSize]->SetItem(dData/m_iSubGroupSize);
			}
			rs.MoveNext();
			pBar->SetPos( (i<<8)/iRecCount );
		}
		delete pBar;
		rs.Close();
		db.Close();
		EndWaitCursor();
		return TRUE;
	}
	CATCH(CDBException, e)
	{
		return FALSE;// A db exception occured. Pop out the details...
	}
	END_CATCH;
}
开发者ID:WisemanLim,项目名称:femos,代码行数:81,代码来源:FoulerDoc.cpp

示例15: wmain

int wmain (int argc,wchar_t ** argv)
{
	CAppData::stdfunc();
	
	_wsetlocale(LC_CTYPE,L".OCP"); 

	SetRegKey(argc,argv);

	if (!SetLanguageSpecifigHandles(argv[0]))
		return 1;

	CArrayFP<CDatabase*> aDatabases;
	
	WORD wCurrentThread=0;

	aDatabases.Add(CDatabase::FromDefaults(TRUE));
	aDatabases[0]->SetNamePtr(alloccopy(L"DEFAULTX"));
	aDatabases[0]->SetThreadId(wCurrentThread);

    int i,helps=0;
#ifndef WIN32
    if (getenv("TZ")==NULL)
		fprintf(stderr,"Timezone is not set. Database may contain invalid file times.\nFor example type "SET TZ=GMT+1" for central european time.\n");
#endif
    for (i=1;i<argc;i++)
    {
        if (argv[i][0]=='-' || argv[i][0]=='/')
        {
            switch (argv[i][1])
			{
			case L'X':
				if (argv[i][2]==L'\0')
				{
					if (i<argc-1)
						i++; // RegKeyName already set
				}
				break;
			case 'l':
			case 'L':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && 
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else if (argv[i][2]=='1')
				{
					aDatabases.GetLast()->AddLocalRoots();
					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				else 
				{
					CStringW* pStr;
					if (argv[i][2]==L'\0' && i+1<argc)
						pStr=new CStringW(argv[++i]);
					else
						pStr=new CStringW(argv[i]+2);
					
					if ((*pStr)[0]==L'\"')
						pStr->DelChar(0);
					if (pStr->LastChar()==L'\"')
						pStr->DelLastChar();
					while (pStr->LastChar()==L'\\')
						pStr->DelLastChar();
					
					if (pStr->GetLength()>1)
					{
						pStr->ReplaceChars('/','\\');
						if ((*pStr)[1]==':' && pStr->GetLength()==2)
							aDatabases.GetLast()->AddRoot(pStr->GiveBuffer());
						else if (FileSystem::IsDirectory(*pStr))
							aDatabases.GetLast()->AddRoot(pStr->GiveBuffer());
						else
							fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr);
					}
					else
						fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr);
					delete pStr;

					aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX"));
				}
				break;
			case 'e':
				if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && 
					wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0)
					wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName());
				else 
				{
					CStringW* pStr;
					if (argv[i][2]=='\0' && i+1<argc)
						pStr=new CStringW(argv[++i]);
					else
						pStr=new CStringW(argv[i]+2);
					
					if ((*pStr)[0]==L'\"')
						pStr->DelChar(0);
					if (pStr->LastChar()==L'\"')
						pStr->DelLastChar();
					while (pStr->LastChar()==L'\\')
						pStr->DelLastChar();
					
					if (pStr->GetLength()>0)
						aDatabases.GetLast()->SetExcludedFiles(*pStr);
//.........这里部分代码省略.........
开发者ID:eladkarako,项目名称:locate32,代码行数:101,代码来源:UpdateDB.cpp


注:本文中的CDatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。