🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1825

Re: conflict with ado and teechart

#1825
From: Walter
Date: Tue, 10 Feb 2004 14:47
124 lines
4244 bytes
Here is my stripped down code that replicates the error

header file
=======

file://---------------------------------------------------------------------
------

#ifndef PlotH
#define PlotH
file://---------------------------------------------------------------------
------

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Chart.hpp>
#include <ExtCtrls.hpp>
#include <Series.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include <ComCtrls.hpp>
#include "test.h"
#include <ADODB.hpp>
#include <DB.hpp>
//--------------------------------------------------------------------------
-
class TPlotForm : public TForm
{
__published: // IDE-managed Components
  TButton *calcButton;
  TChart *Chart1;
  TLineSeries *Series1;
  TADOConnection *ADOConnection1;
  TADODataSet *DataSet;
  void __fastcall calcButtonClick(TObject *Sender);

private: // User declarations
  double PriceBond(AnsiString BondName,bool useNewrfr, double newRfr);
public:  // User declarations
  __fastcall TPlotForm(TComponent* Owner);
};
//--------------------------------------------------------------------------
-
extern PACKAGE TPlotForm *PlotForm;
//--------------------------------------------------------------------------
-
#endif

cpp file
=====
#include <vcl.h>
#pragma hdrstop

#include "Plot.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TPlotForm *PlotForm;
//--------------------------------------------------------------------------
-
__fastcall TPlotForm::TPlotForm(TComponent* Owner)
  : TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TPlotForm::calcButtonClick(TObject *Sender)
{

  double startVal, endVal, Steps;
  startVal = 0.50;
  endVal = 0.51;
  Steps = 0.01;
  double xVal[5];
  double yVal[5];
  int counter = 1;
  xVal[0] = startVal;
  while ( xVal[counter-1] < endVal )
    {
      xVal[counter] = xVal[counter-1]+Steps;
      counter++;
    }
  AnsiString bondName = "TestBond";
  double tempValue = 0;
  double temp;
  for (int i = 0; i < counter; i++)
    {
      yVal[i] = PriceBond(bondName,true, xVal[i]);
    }
  Chart1->Series[0]->Clear();
  for (int i = 0; i<counter; i++){
    Chart1->Series[0]->AddXY(xVal[i],yVal[i]);}
 }//error occurs here
//--------------------------------------------------------------------------
-
double TPlotForm::PriceBond(AnsiString BondName, bool useNewrfr, double
newRfr)
{
  ADOConnection1->Connected = false;
  ADOConnection1->Connected = true;
  DataSet->CommandText = "select * from bond where ID=\""+BondName+"\"";
  DataSet->Open();
  double nominal = DataSet->FieldByName("Nominal")->AsString.ToDouble();
  file://if this is true, error occurs
  bool useYieldCurve= DataSet->FieldByName("UseYieldCurve")->AsBoolean;
  double riskFreeRate;
  if (!useYieldCurve)
    riskFreeRate = DataSet->FieldByName("RiskFreeRate")->AsFloat;
  DataSet->Close();
  double rfr;
    if (useNewrfr)
      rfr = newRfr;
    else
      rfr = riskFreeRate;
  double Value;
  if (!useYieldCurve)
    Value = rfr*nominal;
  else Value = nominal*2;
  ADOConnection1->Connected = false;
  return Value;
}
Technical Details
Message-ID: <4028ef04@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4028c5df@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,d6189872bf4664cd
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-02-10 07:10:25 PST
From: "Walter" <w@w.w>
Newsgroups: borland.public.cppbuilder.database.ado
References: <4028c5df@newsgroups.borland.com>
Subject: Re: conflict with ado and teechart
Date: Tue, 10 Feb 2004 16:47:24 +0200
Lines: 126
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4922.1500
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800
NNTP-Posting-Host: 196.44.195.82
Message-ID: <4028ef04@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076424452 196.44.195.82 (10 Feb 2004 06:47:32 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail