Autor Beitrag
Michaela
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

WIN 2000, Linux ?
D6 Prof
BeitragVerfasst: Mi 23.06.04 15:16 
Hallo, nach der Ausführung des Codes
ausblenden Delphi-Quelltext
1:
2:
3:
4:
DataModule3.Verbindung(Testformular);
   DataModule3.IBDataSet1.Close;
   DataModule3.IBDataSet1.InsertSQL.Text :='Insert into TBL_NISSDaten(...)Values(...)';
   DataModule3.IBDataSet1.Open;

bekomme ich folgende Fehlermeldung : Im Projekt ... ist eine Exception der Klasse EIBClientError aufgetreten.Meldung: 'Leere SQL-Anweisung'...
Warum ? ich habe doch in das Dataset.InsertSQL meine Anweisung hineingeschrieben.

Ausserdem habe ich noch ein Problem bei meinem Datenbankzugriff über IBDAtabase. setzte ich LoginPrompt auf False und gebe Benutzernamen und Passwort an, dann funktionierts. Will ich allerdings mit einer Passwortabfrage über die DB arbeiten (LoginPrompt = true), dann bekomme ich die Meldung, dass mein Benutzer nicht existiert ...

Kann mir jemand helfen?

Michaela
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 23.06.04 15:40 
Hallo!

SQL-Anweisungen, die keinen Cursor zurückliefern (Insert / Update / Delete), müssen mit ExecSQL anstelle von Open ausgeführt werden.

Cu,
Udontknow
Michaela Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

WIN 2000, Linux ?
D6 Prof
BeitragVerfasst: Do 24.06.04 07:10 
Ahhh...tja manchmal braucht man halt nen Denkanstoss. Gelesen hatte ich das schon mal irgenwo :) Danke für die Hilfe.
Aber für die Sache mit der Anmeldung weißt du keinen Rat oder? Ich versteh das einfach nicht.
Michaela Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

WIN 2000, Linux ?
D6 Prof
BeitragVerfasst: Do 24.06.04 07:29 
Hmm war anscheinend doch nicht die richtige Lösung. Es geht immer noch nicht:?: Die Fehlermeldung ist noch die selbe.
Hier noch mal meine komplette DB-Verbindung. Vielleicht hab ich ja noch was anderes vergessen
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
unit TestIBVerbindung;
interface
uses
  OracleConnect,InterbaseConnect, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids;

type
  TTestformular = class(TForm)
    IBButton: TButton;
    procedure IBButtonClick(Sender: TObject);
  private

    { Private-Deklarationen }
  public
     { Public-Deklarationen }
  end;

var
  Testformular: TTestformular;

implementation

procedure TTestformular.IBButtonClick(Sender: TObject);
begin
   try
    DataModule3.Verbindung(Testformular);
    DataModule3.IBDataSet1.Close;
    DataModule3.IBDataSet1.InsertSQL.Text :='Insert into TBL(Feld1, Feld2, Feld3,feld4)Values(''A'',''B'',''C'',''D'')';
    DataModule3.IBDataSet1.ExecSQL;
   finally DataModule3.IBDatabase1.Connected := false;
   end;
end;  //Prozedure    IBButtonCLick
end.

unit InterbaseConnect;
interface
uses
  SysUtils, Classes, DB, IBDatabase, IBSQL, IBCustomDataSet, IBQuery;

type

  TDataModule3 = class(TDataModule)
    IBDatabase1: TIBDatabase;
    IBTransaction1: TIBTransaction;
    IBDataSet1: TIBDataSet;
    procedure Verbindung(Sender: TOBject);
  private
    { Private-Deklarationen }
  public

    { Public-Deklarationen }
  end;

var
  DataModule3: TDataModule3;

implementation

procedure TDataModule3.Verbindung (Sender: TObject);
begin
     IBDatabase1.Open;
end;
end.


Und die Einstellung der Komponenten sieht wie folgt aus:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
bject DataModule3: TDataModule3
  OldCreateOrder = False
  Left = 355
  Top = 119
  Height = 150
  Width = 540
  object IBDatabase1: TIBDatabase
    Connected = True
    DatabaseName = 'Localhost:C:\Datenbank\Konsoldb.gdb'
    Params.Strings = (
      'user_name=sysdba'
      'Password=masterkey'
      )
    LoginPrompt = False
    DefaultTransaction = IBTransaction1
    IdleTimer = 0
    SQLDialect = 3
    TraceFlags = []
    Left = 48
    Top = 56
  end
  object IBTransaction1: TIBTransaction
    Active = False
    DefaultDatabase = IBDatabase1
    AutoStopAction = saNone
    Left = 136
    Top = 64
  end
  object IBSQL1: TIBSQL
    Database = IBDatabase1
    ParamCheck = True
    Transaction = IBTransaction1
    Left = 8
    Top = 16
  end
  object IBDataSet1: TIBDataSet
    Database = IBDatabase1
    Transaction = IBTransaction1
    BufferChunks = 1000
    CachedUpdates = False
    InsertSQL.Strings = (
      )
    SelectSQL.Strings = (
      )
    Left = 168
    Top = 8
  end
end
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Do 24.06.04 07:56 
Oh, da habe ich was übersehen gehabt, ich arbeite eigentlich auch immer mit DBExpress. Probier mal, anstelle "insertsql" "selectsql" zu verwenden.

Cu,
Udontknow
Michaela Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

WIN 2000, Linux ?
D6 Prof
BeitragVerfasst: Do 24.06.04 08:17 
:D Freu es funktioniert... Ich hab den Datensatz endlich in meiner TBL. Aber mal ne Frage nebenbei: wenn ich für eine Insert Anweisung SelectSQL verwende, wofür ist dann Insertsql da. Hab ich da was falsch verstanden?

Danke für deine Hilfe Udontknow.Michaela
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Do 24.06.04 11:44 
Hi
Die verschiedenen SQL-Statements werden durch die entsprechenden Methoden des IBDatasets ausgelöst. Die Anweisungen im SelectSQL werden immer dann ausgeführt, wenn du Daten abrufst. Also beim Öffnen, beim Lesen usw. InsertSQL wird ausgelöst wenn du die Methode .Insert des Datasets verwendest.

Das was du hier tust funktioniert zwar, ist aber nicht gerade verständlich. Wenn du deine Daten direkt mit SQL-Anweisungen in die Datenbank schreiben willst, dann wäre die IBSQL-Komponente die bessere (und efizientere) Wahl.

Oder du verwendest die Methoden von IBDataset (.Insert, .Edit, .Post) und arbeitest damit praktisch wie mit einer TTable-Komponente. Da ist die einfachere Variante.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...