Rave - Data Connections
I need to be able to change the AuthDesign property of my database connection at runtime so that I can connect to different servers depending on my customer's server settings. How would I do that?
Changing your database connection properties prior to executing a report can easily be done as indicated below. The example uses parameters needed to make an Interbase connection. The DataSource property may change depending on the database that you are using. To see the format needed for this property simply place a break point on the code just prior to the DataSource property being assigned and you will be able to see what is expected in this property. This is assuming that you have set up the Database property correctly in the Rave Designer.
Delphi Example:
uses RvDLInterbase, RvDatabase; procedure TForm1.Button1Click(Sender: TObject); var Database: TRaveDatabase; begin RvProject1.Open; Database := TRaveDatabase(RvProject1.ProjMan.FindRaveComponent('Database1', nil)); if Assigned(Database) then begin Database.AuthRun.Datasource := 'ServerIP:/datapath/test.gdb'; Database.AuthRun.Username := 'sysdba'; Database.AuthRun.Password := 'ThePassword'; end; { if } RvProject1.ExecuteReport('Report1'); end;
C++Builder Example:
void __fastcall TForm1::Button1Click(TObject *Sender) { TRaveDatabase* Database; RvProject1->Open(); Database = dynamic_cast(RvProject1->ProjMan->FindRaveComponent("Database1", NULL)); if (Database != NULL) { Database->AuthRun->Datasource = "ServerIP:/datapath/test.gdb"; Database->AuthRun->Username = "sysdba"; Database->AuthRun->Password = "ThePassword"; }// if RvProject1->ExecuteReport("Report1"); }