Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Prism STAThreadAttribute erfordelich (https://www.delphipraxis.net/108948-stathreadattribute-erfordelich.html)

Pumba 21. Feb 2008 16:31


STAThreadAttribute erfordelich
 
Hallo,

Versuche gerade eine Datenbank MSSQL über die IWComponenten zu erstellen dabe bekomme ich die Fehlermeldung "Ungültiges Thread-Modell(STAThreadAttribute erforderlich)

Auf der Form Sind SQLConnection, SQLDataSet, DataSetProvider, ClientDataset, DataSource, IWEdit, IWButton und IWDBGrid
und folgenden Code
Code:
unit Unit1;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWCompEdit,
  System.ComponentModel, Borland.Vcl.Controls, IWVCLBaseControl, IWBaseControl,
  IWBaseHTMLControl, IWControl, IWCompButton, IWDBStdCtrls, DBXpress, FMTBcd,
  Borland.Vcl.Db, Borland.Vcl.SqlExpr, IWGrids, IWDBGrids, Borland.Vcl.DBClient,
  Borland.Vcl.Provider, IWCompLabel;

type
  TIWForm1 = class(TIWAppForm)
    IWButton1: TIWButton;
    IWEdit1: TIWEdit;
    IWDBGrid1: TIWDBGrid;
    SQLConnection1: TSQLConnection;
    DataSource1: TDataSource;
    SQLDataSet1: TSQLDataSet;
    DataSetProvider1: TDataSetProvider;
    ClientDataSet1: TClientDataSet;
    IWLabel1: TIWLabel;
    IWLabel2: TIWLabel;
    procedure IWButton1Click(Sender: TObject);
  public
  end;

implementation

{$R *.nfm}

procedure TIWForm1.IWButton1Click(Sender: TObject);
var
 ZahlDS : Integer;
 DatBegin : String;

begin
ClientDataSet1.Active := False;
IWLabel2.Caption :='Beginne mit Abfrage';

SQLDataSet1.CommandText := 'select * from tbl_ID_ok_Test' +
        ' where Station Like '''+IWEdit1.Text +'%''';
ClientDataSet1.Active := True;
ZahlDS := ClientDataSet1.RecordCount;
IWLabel1.Caption := IntToStr(ZahlDS)+' Datensätze';

end;

initialization

  TIWForm1.SetAsMainForm(typeof(TIWForm1));


end.

und hier die Project Datei
Code:
program Project1;


uses
  Borland.Vcl.Forms,
  IWInitDotNet,
  IWLicenseKey,
  IWMain,
  NETHandlerApp,
  Unit1 in 'Unit1.pas' {IWForm1: TIWAppForm},
  ServerController in 'ServerController.pas' {IWServerController: TIWServerControllerBase},
  UserSessionUnit in 'UserSessionUnit.pas' {IWUserSession: TIWUserSessionBase};

{$R *.RES}
[STAThread]
begin
  Application.Initialize;
  Application.CreateForm(TFormIWMain, FormIWMain);
  Application.Run;
end.

Wenn ich die Tabelle Direkt mit den komponenten binde funktioniert es
ist mein erster Versuch bei den Win Anwendungen klappt es

Danke im vorraus

Pumba


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:20 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz