products/sources/formale Sprachen/Delphi/Autor 0.7 image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: cardfile.csv   Sprache: Delphi

unit DBAccess;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
interface
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
uses
  Math, SysUtils, MySQL,
  Utilities, StrUtils, Dialogs;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
const
  em=4000;
  host='co';
  port=1653;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
var
 MySQL:  PMYSQL;
 MyTime: longword;
 MyComp: integer;
 user:String;
 password:String;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure SQLConnect(MyHost:string;MyPort: integer;MyUser: string;MyPass: string);
procedure SQLSelect(Produktkey:String;var Produktid :String;var Edition: String);
function  SQLSelectMultiple():integer;
procedure SQLUpdate(Produktkey:String;WinId,IPaddr,CPU,Disk,EthernetAddr:String);
function  SQLFeedback(Vorname, Name, Email, Title, Version, Sprache,Itemindex, Kommentar, IP, Country :String):integer;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
implementation
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure SQLSelect(Produktkey:String;var Produktid :String;var Edition: String);
var
  SQLRes: PMYSQL_RES;
  SQLstmt: Ansistring;
  SQLCode:integer;
  Row: PMYSQL_ROW;
  Lengths: PMYSQL_LENGTHS;
  Aktivierung,WinId:String;
begin
  //Produktkey:=UpperCase(Produktkey);
  sqlcode:=0;
  SQLConnect(host+host+host+'.de',port*2,User,Password);
  SQLstmt := 'select Produkt, Edition, Aktivierung, WinProdId from licences.license'
           + ' where Produktkey="'+Produktkey+'";';
  try
    //-- mysql_query
    sqlcode:= mysql_query(MySQL, pChar(SQLstmt));
  except
    error(em+51,'Schlüssel='+ProduktId+' Ergebnis='+IntToStr(SQLCode))
  end;
  if sqlcode=0 then begin
    SQLRes := mysql_use_result(MySQL);
    if SQLRes = nil then
      Produktid:=''
    else try
      Row := mysql_fetch_row(SQLRes);
      Lengths := mysql_fetch_lengths(SQLRes);
      SetString(ProduktId, Row[0], Lengths[0]);
      SetString(Edition, Row[1], Lengths[1]);
      SetString(Aktivierung, Row[2], Lengths[2]);
      SetString(WinId, Row[3], Lengths[3]);
      if Aktivierung<>'000-00-00' then begin      // Reaktivierung
        if WinId<>GetWinProductId then begin
          ProduktId:='';
          Edition:='';
        end;
      end;
    finally
    end
  end else begin
    error(em+60,'Schlüssel='+ProduktId+' Ergebnis='+IntToStr(SQLCode))
  end;
//-- mysql_close
  mysql_close(MySQL);
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure SQLConnect(MyHost:string;MyPort: integer;MyUser: string;MyPass:string);
begin
 try
   MySQL := mysql_init(nil);
   if MySQL = nil then
     error(em+52,'Keine Verbindung zur Datenbank');
   MyTime := 30;
   if mysql_options(MySQL, MYSQL_OPT_CONNECT_TIMEOUT, @MyTime) <> 0 then
     error(em+53,'Keine Verbindung zur Datenbank');
   MyComp:=0*CLIENT_COMPRESS;
   if mysql_real_connect(MySQL, pChar(MyHost), pChar(MyUser),
     pChar(MyPass), nil, MyPort, nil, MyComp) = nil then
     error(em+54,'Keine Verbindung zur Datenbank');
   if mysql_connect(MySQL, pChar(MyHost), pChar(MyUser), pChar(MyPass)) = nil then
     error(em+55,'Keine Verbindung zur Datenbank');
 except
 end;
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
function SQLFeedback(Vorname, Name, Email, Title, Version, Sprache,
                     Itemindex, Kommentar, IP, Country :String):integer;
var
  Query,Hostname,IPAddr,WSAErr: String;
  sqlcode: integer;
const
   Spaces = ' ';
begin
  GetOwnIP(HostName,IPAddr, WSAErr);
  SQLConnect(host+host+host+'.de',port*2,User,Password);
  Query := 'insert into feedbacks.feedback '
         + ' (Datum, Vorname, Name, Email, Produkt, '
         + ' Version, Sprache, Bewertung, Kommentar, '
         + ' IP, Hostname, Country) '
         + ' values( CURRENT_TIMESTAMP '
         + ' ,"'+Vorname+'" '
         + ' ,"'+Name+'" '
         + ' ,"'+Email+'" '
         + ' ,"'+Title+'" '
         + ' ,"'+Version+'" '
         + ' ,"'+Sprache+'" '
         + ' ,'+ItemIndex+' '
         + ' ,"'+Kommentar+'" '
         + ' ,"'+IPAddr+'"'
         + ' ,"'+HostName+'"'
         + ' ,"'+Country+'")';
  try
    //-- mysql_query
    sqlcode:= mysql_query(MySQL, pChar(Query));
    Result:=sqlcode;
  finally
    //-- mysql_close
    mysql_close(MySQL);
  end;
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure SQLUpdate(Produktkey:String;WinId,IPaddr,CPU,Disk,EthernetAddr:String);
var
  Hostname,WSAErr: String;
  SQLstmt: Ansistring; SQLCode:integer;
begin
  //ProduktKey:=UpperCase(Produktkey);
  GetOwnIP(HostName,IPAddr, WSAErr);
  SQLConnect(host+host+host+'.de',port*2,User,Password);
  SQLstmt := 'update licences.license'
         + ' set WinProdId="'+WinId+'" '
         + ' , IP="'+IPaddr+'" '
         + ' , CPU="'+CPU+'" '
         + ' , Disk="'+Disk+'" '
         + ' , Ethernet="'+EthernetAddr+'" '
         + ' , Aktivierung=CURDATE() '
         + ' where Produktkey="'+Produktkey+'";';
  try      //-- mysql_query
    sqlcode:= mysql_query(MySQL, pChar(SQLstmt));
  finally  //-- mysql_close
    mysql_close(MySQL);
  end;
  if sqlcode<>0 then
   error(em+56,'Ergebnis='+inttostr(sqlcode));
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
function SQLSelectMultiple():integer;
var
  Query: String;
  SQLRes: PMYSQL_RES;
  //Result: PMYSQL_RES;
  Line: string;
  Field: PMYSQL_FIELD;
  FieldCount: longword;
  Lengths: PMYSQL_LENGTHS;
  Row: PMYSQL_ROW;
  I,sqlcode: integer;
  Buffer: string;
const
   Spaces = ' ';
begin
  Result:=0;
  SQLConnect(host+host+host+'.de',port*2,User,Password);
  Query := 'select * from feedbacks.feedback;';
  //-- mysql_query
  sqlcode:= mysql_query(MySQL, pChar(Query));
  if sqlcode<> 0 then
    error(em+57,'MySQL Fehler' + IntToStr(sqlcode));
  //-- mysql_use_result
  SQLRes := mysql_use_result(MySQL);
  if SQLRes = nil then
    error(em+58,'Keine Verbindung zur Datenbank');
  try
    Line := '';
    //-- mysql_fetch_field
    Field := mysql_fetch_field(SQLRes);
    while Field <> nil do begin
      if Line <> '' then begin
       Line:=Line+' ';
      end;
      Line:=Line+copy(Field.name + Spaces, 1, Field.length);
      //-- mysql_fetch_field
      Field := mysql_fetch_field(SQLRes);
    end;
    //-- mysql_num_fields
    FieldCount := mysql_num_fields(SQLRes);
    // mysql_fetch_row
    Row := mysql_fetch_row(SQLRes);
    while Row <> nil do begin
      Line := '';
      //-- mysql_fetch_lengths
      Lengths := mysql_fetch_lengths(SQLRes);
      if Lengths = nil then
        error(em+59,'Keine Verbindung zur Datenbank');
      for I := 0 to FieldCount - 1 do begin
       if Line <> '' then Line:=Line+' ';
       SetString(Buffer, Row[I], Lengths[I]);
       //-- mysql_fetch_field_direct
       Line:=Line+copy(Buffer + Spaces, 1, mysql_fetch_field_direct(SQLRes, I).length);
      end;
      //-- mysql_fetch_row
      Row := mysql_fetch_row(SQLRes);
    end;
    //-- mysql_eof
    if mysql_eof(SQLRes) = 0 then
        error(em+60,'Keine Verbindung zur Datenbank');
  finally
     //-- mysql_free_result
     mysql_free_result(SQLRes);
     mysql_close(MySQL);
  end;
end;
{------------------------------------------------------------------}
{-                                                                -}
{-   Ende dieser Quelle                                           -}
{-                                                                -}
{------------------------------------------------------------------}
end.


 

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet)  ¤





Druckansicht
unsichere Verbindung
Druckansicht
sprechenden Kalenders

in der Quellcodebibliothek suchen




Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.


Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff