
sub PreCreateForm ()
{
   my $cRecord;
   my $pDbHdl;
   my $pStmtHdl;
   my @lResult = ();


   if(&GetAttr("LastBtn") ne "BtnNext")
   {

      &SetField("DbDriver",
                $oSessionGL->getState("CreateDbRc,DbDriver"));
      &SetField("Database",
                $oSessionGL->getState("CreateDbRc,Database"));
      &SetField("Host",
                $oSessionGL->getState("CreateDbRc,Host"));
       &SetField("User",
                $oSessionGL->getState("CreateDbRc,User"));
      &SetField("Password",
                $oSessionGL->getState("CreateDbRc,Password"));
   }

   @lResult = DBI->data_sources(&GetField("DbDriver"));

   foreach (@lResult)
   {
      # Remove the dbi:driver:-part
      s/(.*:)([^:]+)/$2/;


      # remove the description, if it exists
      if(/(.*)=(.*)/)
      {
         $_ = $2;
      }
   }

   &MySetVal("Layout Field Database", "Values",
             join "\n", @lResult);
}


sub Check_DbRc_DbDriver()
{
   &AddError("Database", "Please select a database")
       if(!&GetField("Database"));
}



sub MyBtnNext ()
{
   &CheckRecord();

   if(!&GetField("Database"))
   {
      &GenPage();
   }
   else
   {
      $oSessionGL->setState("CreateDbRc,Database", &GetField("Database"));
      $oSessionGL->setState("CreateDbRc,Host",     &GetField("Host"));
      $oSessionGL->setState("CreateDbRc,User",     &GetField("User"));
      $oSessionGL->setState("CreateDbRc,Password", &GetField("Password"));

      print &Redirect(&GetAttr("SessionId"), "WWWdb:Wiz:CreateDbRc_3");
   }
}


sub MyBtnPrev ()
{
   print &Redirect(&GetAttr("SessionId"), "WWWdb:Wiz:CreateDbRc_1");
}

1;





