|
![]() |
|
Registriert seit: 14. Jun 2005 139 Beiträge |
#1
Also der Fehler ist weiter oben als jpg, der gesamte code kommt jetzt.^^
Delphi-Quellcode:
So und jetzt das mit den Bildern:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, DB, ZSqlMetadata, ZAbstractTable, ZDataset, ZAbstractRODataset, ZAbstractDataset, DBCtrls, ZConnection, Unit3, Inifiles, jpeg; type TForm1 = class(TForm) GroupBox1: TGroupBox; GroupBox3: TGroupBox; test: TListView; edVorname: TEdit; edName: TEdit; edAdresse: TEdit; edPLZ: TEdit; edWohnort: TEdit; edID: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Button1: TButton; Button2: TButton; GroupBox2: TGroupBox; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; edServer: TEdit; edLogin: TEdit; edPasswort: TEdit; edDB: TEdit; Button3: TButton; qrMain: TZQuery; trMain: TZSQLMetadata; dsMain: TDataSource; dbmain: TZConnection; Button5: TButton; Button6: TButton; Button4: TButton; Button8: TButton; Button9: TButton; Button10: TButton; Button11: TButton; procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure testSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); procedure BilderClick(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button10Click(Sender: TObject); procedure Button11Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation uses Unit4; {$R *.dfm} procedure TForm1.Button3Click(Sender: TObject); begin dbMain.Hostname:=edServer.Text; dbMain.User:=edLogin.Text; dbMain.Password:=edPasswort.Text; dbMain.Database:=edDB.Text; dbMain.Connected:=True; try qrMain.SQL.Text:='CREATE TABLE `adressbuch` ('+ '`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,'+ '`vorname` TEXT NOT NULL,'+ '`name` TEXT NOT NULL,'+ '`adresse` TEXT NOT NULL,'+ '`wohnort` TEXT NOT NULL,'+ '`plz` INT NOT NULL'+ ');'; qrMain.ExecSql; finally dbMain.Connected:=False; end; end; procedure TForm1.Button2Click(Sender: TObject); begin dbMain.Hostname:=edServer.Text; dbMain.User:=edLogin.Text; dbMain.Password:=edPasswort.Text; dbMain.Database:=edDB.Text; dbMain.Connected:=True; dbMain.Connected:=True; //Verbindung herstellen try qrMain.SQL.Text:='INSERT INTO `adressbuch` '+ '(`id`, `vorname`, `name`, `adresse`, `wohnort`, `plz`)'+ ' VALUES '+ '('''', '''+edVorname.Text+''', '''+edName.Text+ ''', '''+edAdresse.Text+''', '''+edWohnort.Text+ ''', '''+edPLZ.Text+''');'; qrMain.ExecSql; //SQL-Statement ausführen finally dbMain.Connected:=False; //Verbindung trennen end; end; procedure TForm1.Button5Click(Sender: TObject); begin dbMain.Hostname:=edServer.Text; dbMain.User:=edLogin.Text; dbMain.Password:=edPasswort.Text; dbMain.Database:=edDB.Text; dbMain.Connected:=True; try qrMain.SQL.Text:='DELETE FROM adressbuch WHERE id='''+edID.Text+''';'; qrMain.ExecSql; finally dbMain.Connected:=False; end; end; procedure TForm1.Button6Click(Sender: TObject); var ListItem: TListItem; begin dbMain.Hostname:=edServer.Text; dbMain.User:=edLogin.Text; dbMain.Password:=edPasswort.Text; dbMain.Database:=edDB.Text; dbMain.Connected:=True; try test.Items.Clear; qrMain.SQL.Text:='Select * from `adressbuch` order by name;'; qrMain.Open; while not qrMain.Eof do begin ListItem := test.Items.Add; ListItem.Caption:=qrMain.FieldByName('id').AsString; ListItem.SubItems.Add(qrMain.FieldByName('vorname').AsString); ListItem.SubItems.Add(qrMain.FieldByName('name').AsString); ListItem.SubItems.Add(qrMain.FieldByName('adresse').AsString); ListItem.SubItems.Add(qrMain.FieldByName('plz').AsString); ListItem.SubItems.Add(qrMain.FieldByName('wohnort').AsString); qrMain.Next; end; finally dbMain.Connected:=False; end; end; procedure TForm1.Button1Click(Sender: TObject); begin dbMain.Hostname:=edServer.Text; dbMain.User:=edLogin.Text; dbMain.Password:=edPasswort.Text; dbMain.Database:=edDB.Text; dbMain.Connected:=True; try qrMain.SQL.Text:='UPDATE `adressbuch` Set `vorname`='''+edVorname.Text+''','+ '`name`='''+edName.Text+''','+ '`adresse`='''+edAdresse.Text+''','+ '`plz`='''+edPLZ.Text+''','+ '`wohnort`='''+edWohnort.Text+''' '+ 'WHERE `id`='''+edID.Text+''';'; qrMain.ExecSql; //SQL-Statement ausführen finally dbMain.Connected:=False; end; end; procedure TForm1.testSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); begin edID.Text := Item.Caption; edVorname.Text := Item.SubItems[0]; edName.Text := Item.SubItems[1]; edAdresse.Text := Item.SubItems[2]; edPLZ.Text := Item.SubItems[3]; edWohnort.Text := Item.SubItems[4]; end; procedure TForm1.BilderClick(Sender: TObject); //var copyedit1: TStrings; var IniFile: TIniFile; begin try IniFile:=TInifile.Create(ExtractFilePath(ParamStr(0))+'login.ini'); IniFile.WriteString('Host','Host', edServer.Text); IniFile.WriteString('User','Login', edLogin.Text); IniFile.WriteString('Pass','Passwort', edPasswort.Text); IniFile.WriteString('Database','Datenbank', edDB.Text); finally IniFile.Free; end; //copyedit1:=TStringlist.Create; //copyedit1.Add(edserver.Text); //copyedit1.Add(edLogin.Text); //copyedit1.Add(edPasswort.Text); //copyedit1.Add(edDB.Text); //copyedit1.SaveToFile('logindaten.ini'); //copyedit1.Free; end; procedure TForm1.Button8Click(Sender: TObject); begin Form1.Close; end; procedure TForm1.Button9Click(Sender: TObject); begin Form3.Show; end; procedure TForm1.Button10Click(Sender: TObject); var IniFile: TIniFile; begin try IniFile:=TInifile.Create(ExtractFilePath(ParamStr(0))+'login.ini'); edServer.Text:=IniFile.ReadString('Host','Host', ''); edLogin.Text:=IniFile.ReadString('User','Login', ''); edPasswort.Text:=IniFile.ReadString('Pass','Passwort', ''); edDB.Text:=IniFile.ReadString('Database','Datenbank', ''); finally IniFile.Free; end; end; procedure TForm1.Button11Click(Sender: TObject); begin Form4.show; end; end.
Delphi-Quellcode:
unit Unit4;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Unit1, StdCtrls, ExtCtrls, jpeg; type TForm4 = class(TForm) ListBox1: TListBox; Button1: TButton; Image1: TImage; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form4: TForm4; implementation {$R *.dfm} procedure ListAllPics(sPath: string; List: TStrings); var Rec: TSearchRec; begin List.BeginUpdate; List.Clear; if sPath[Length(sPath)] <> '\' then sPath := sPath + '\'; if FindFirst(sPath + '*.*',faAnyfile,Rec) = 0 then begin repeat if (AnsiLowerCase(ExtractFileExt(Rec.Name)) = '.jpeg') or (AnsiLowerCase(ExtractFileExt(Rec.Name)) = '.jpg') then List.Add(Rec.Name); until FindNext(Rec) <> 0; FindClose(Rec); end; List.EndUpdate; end; procedure TForm4.FormCreate(Sender: TObject); begin ListAllPics('C:\Dokumente und Einstellungen\Sebastian\Desktop\Programmieren\Mysqlconnect\Pics\'+Form1.edID.text ,Listbox1.Items); end; procedure TForm4.Button1Click(Sender: TObject); begin image1.Picture.Create; try image1.Picture.LoadFromFile('C:\Dokumente und Einstellungen\Sebastian\Desktop\Programmieren\Mysqlconnect\Pics\'+Form1.edID.text +'\' +Listbox1.Items[ListBox1.ItemIndex]); finally image1.Picture.Free; end; end; end. |
![]() |
Ansicht |
![]() |
![]() |
![]() |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
![]() |
![]() |