Einzelnen Beitrag anzeigen

WS1976
(Gast)

n/a Beiträge
 
#24

Re: Probleme mit mysql und zquery (zeoslib)

  Alt 30. Dez 2007, 12:01
Hallo,

folgender Ablauf:
Delphi-Quellcode:
   qrmain.Active:=true;
-->
procedure TZAbstractRODataset.InternalOpen;
var
  ColumnList: TObjectList;
begin
  CheckSQLQuery;
  CheckConnected;

  CurrentRow := 0;
  FetchCount := 0;
  CurrentRows.Clear;

  Connection.ShowSQLHourGlass;
  try
    { Creates an SQL statement and resultsets }
    if FSQL.StatementCount> 0 then
      ResultSet := CreateResultSet(FSQL.Statements[0].SQL, -1)
    else
      ResultSet := CreateResultSet('', -1);
    if not Assigned(ResultSet) then
    begin
      if not (doSmartOpen in FOptions) then
        raise Exception.Create(SCanNotOpenResultSet)
      else Exit;
    end;

    { Initializes field and index defs. }
    InternalInitFieldDefs;

    if DefaultFields and not FRefreshInProgress then
      CreateFields;
    BindFields(True);

    { Initializes accessors and buffers. }
    ColumnList := ConvertFieldsToColumnInfo(Fields);
    try
      RowAccessor := TZRowAccessor.Create(ColumnList);
    finally
      ColumnList.Free;
    end;
    FOldRowBuffer := PZRowBuffer(AllocRecordBuffer);
    FNewRowBuffer := PZRowBuffer(AllocRecordBuffer);

    FieldsLookupTable := CreateFieldsLookupTable(Fields);
    InitFilterFields := False;

    IndexFields.Clear;
    GetFieldList(IndexFields, FLinkedFields); {renamed by bangfauzan}

    { Performs sorting. }
    if FSortedFields <> 'then
      InternalSort;
  finally
    Connection.HideSQLHourGlass;
  end;
end;
bei InternalInitFieldDefs;

Delphi-Quellcode:
procedure TZAbstractRODataset.InternalInitFieldDefs;
var
  I, J, Size: Integer;
  AutoInit: Boolean;
  FieldType: TFieldType;
  ResultSet: IZResultSet;
  FieldName: string;
  FName: string;
begin
  FieldDefs.Clear;
  ResultSet := Self.ResultSet;
  AutoInit := ResultSet = nil;

  try
    { Opens an internal result set if query is closed. }
    if AutoInit then
    begin
      CheckSQLQuery;
      CheckConnected;
      ResultSet := CreateResultSet(FSQL.Statements[0].SQL, 0);
    end;
    if not Assigned(ResultSet) then
      raise Exception.Create(SCanNotOpenResultSet);

    { Reads metadata from resultset. }

    with ResultSet.GetMetadata do
    begin
      if GetColumnCount > 0 then for I := 1 to GetColumnCount do
      begin
---->>>> hier wird Exception ausgelöst:
        FieldType := ConvertDbcToDatasetType(GetColumnType(I));

        if FieldType in [ftString, ftWidestring, ftBytes] then
          Size := GetPrecision(I)
        else Size := 0;

        J := 0;
        FieldName := GetColumnLabel(I);
        FName := FieldName;
        while FieldDefs.IndexOf(FName) >= 0 do
        begin
          Inc(J);
          FName := Format('%s_%d', [FieldName, J]);
        end;

        with TFieldDef.Create(FieldDefs, FName, FieldType,
          Size, False, I) do
        begin
          {$IFNDEF FPC}
{$IFNDEF FOSNOMETA}
          Required := IsWritable(I) and (IsNullable(I) = ntNoNulls);
{$ENDIF}
          {$ENDIF}
{$IFNDEF FOSNOMETA}
          if IsReadOnly(I) then Attributes := Attributes + [faReadonly];
          Precision := GetPrecision(I);
{$ENDIF}
          DisplayName := FName;
        end;
      end;
    end;

  finally
    { Closes localy opened resultset. }
    if AutoInit then
    begin
      if ResultSet <> nil then
      begin
        ResultSet.Close;
        ResultSet := nil;
      end;
      if Statement <> nil then
      begin
        Statement.Close;
        Statement := nil;
      end;
    end;
  end;
end;
Grüsse Rainer (ich weiss dass das ne Zumutung ist aber besser krieg ichs nicht hin)
  Mit Zitat antworten Zitat