raised exeption class EMSError with message 'Invalid object name'UQDistDeptTBL'.'.
Posted: Mon 11 May 2015 02:18
I have something happening that I am not quite sure how to decipher. Here is the error code-
project assets.exe raised exeption class EMSError with message 'Invalid object name'UQDistDeptTBL'.'.
UQDistDeptTBL is a TUniQuery Object. It is simply acessing an empty table and the errors happens when it calls .Open. When it breaks, it is the Data.DB file with the following procedure..(line it is highlighting at the break = ****)
procedure TDataSet.DoInternalOpen;
begin
FAutomaticFieldsScope := True;
InternalOpen;
FInternalOpenComplete := True;*****
UpdateBufferCount;
FBOF := True;
Why is returning "Invalid Object Name UQDistDeptTBL which is a valid TUniQuery object?
If someone could point me in the right direction...
Here is the uncleaned up code from the form that is active...Please excuse some sloppy coding that I need to add some routines to.
Thank you....
Steve
project assets.exe raised exeption class EMSError with message 'Invalid object name'UQDistDeptTBL'.'.
UQDistDeptTBL is a TUniQuery Object. It is simply acessing an empty table and the errors happens when it calls .Open. When it breaks, it is the Data.DB file with the following procedure..(line it is highlighting at the break = ****)
procedure TDataSet.DoInternalOpen;
begin
FAutomaticFieldsScope := True;
InternalOpen;
FInternalOpenComplete := True;*****
UpdateBufferCount;
FBOF := True;
Why is returning "Invalid Object Name UQDistDeptTBL which is a valid TUniQuery object?
If someone could point me in the right direction...
Here is the uncleaned up code from the form that is active...Please excuse some sloppy coding that I need to add some routines to.
Thank you....
Steve
Code: Select all
unit f.districts;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, DBAccess, Uni, MemDS,
UniProvider, SQLServerUniProvider, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.DBCtrls,
Vcl.Menus, Vcl.Grids, Vcl.DBGrids, Vcl.ComCtrls, U.Resize, F.DistrictsEdit,
DAScript, UniScript, F.Floors, F.DistDept;
type
TDistricts = class(TForm)
SQLServerUniProvider1: TSQLServerUniProvider;
UCAssets: TUniConnection;
UDSDistrictTBL: TUniDataSource;
UQDistrictTBL: TUniQuery;
UQDistrictTBLDistName: TStringField;
UQDistrictTBLDistSchoolName: TStringField;
UQDistrictTBLDistAbbrev: TStringField;
UQDistrictTBLDistrictNotes: TMemoField;
BClose: TButton;
UDSDistLocationTBL: TUniDataSource;
UQDistLocationTBL: TUniQuery;
UQDistDeptTBL: TUniQuery;
UDSDistDeptTBL: TUniDataSource;
MainMenu1: TMainMenu;
File1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
EditDistricts1: TMenuItem;
LBDistricts: TListBox;
LDistrictList: TLabel;
DBGDistLocationTBL: TDBGrid;
Label1: TLabel;
DBGDistRoomsTBL: TDBGrid;
UQDistRoomTBL: TUniQuery;
UDSDistRoomTBL: TUniDataSource;
UQDistRoomTBLDistRmID: TLargeintField;
UQDistRoomTBLLocIDNo: TSmallintField;
UQDistRoomTBLITFriendlyName: TStringField;
UQDistRoomTBLRoomNo: TStringField;
UQDistRoomTBLRoomFriendlyName: TStringField;
UQDistRoomTBLFloor: TStringField;
UQDistRoomTBLDistRoomNotes: TMemoField;
UQDistRoomTBLDeptIDNo: TLargeintField;
DistrictsandLocations1: TMenuItem;
Floors1: TMenuItem;
UQDistrictTBLDistIDNo: TLargeintField;
UQDistLocationTBLLocIDNo: TSmallintField;
UQDistLocationTBLDistIDNo: TLargeintField;
UQDistLocationTBLStrAddr1: TStringField;
UQDistLocationTBLStrAddr2: TStringField;
UQDistLocationTBLStrAdd3: TStringField;
UQDistLocationTBLCity: TStringField;
UQDistLocationTBLState: TStringField;
UQDistLocationTBLZip: TStringField;
DBNavigator1: TDBNavigator;
DBREDistRoomNotes: TDBRichEdit;
UQDistLocationTBLDescription: TMemoField;
DBRELocationDescription: TDBRichEdit;
LDistLocationNotes: TLabel;
Label3: TLabel;
LLocationRoomNotes: TLabel;
Departments1: TMenuItem;
UQDistFloorsTBL: TUniQuery;
UDSDistFloorsTBL: TUniDataSource;
LBDistDept: TListBox;
LDepartments: TLabel;
UQDistDeptTBLDeptIDNo: TLargeintField;
UQDistDeptTBLDistIDNo: TLargeintField;
UQDistDeptTBLDistDeptName: TStringField;
UQDistDeptTBLDistDeptDesc: TStringField;
procedure ResizeTDBGridColumns;
procedure FormShow(Sender: TObject);
Procedure PopulateDistrictBox;
procedure LBDistrictsClick(Sender: TObject);
procedure DistrictsandLocations1Click(Sender: TObject);
procedure Floors1Click(Sender: TObject);
procedure Departments1Click(Sender: TObject);
procedure UQDistLocationTBLAfterScroll(DataSet: TDataSet);
procedure UpdateDepartments;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Districts: TDistricts;
implementation
{$R *.dfm}
procedure TDistricts.Departments1Click(Sender: TObject);
begin
DistDept := TDistDept.Create(NIL);
DistDept.ShowModal;
DistDept.Free;
end;
procedure TDistricts.DistrictsandLocations1Click(Sender: TObject);
begin
DistrictsEdit := TDistrictsEdit.Create(Nil);
DistrictsEdit.ShowModal;
DistrictsEdit.Free;
end;
procedure TDistricts.Floors1Click(Sender: TObject);
begin
Floors := TFloors.Create(Nil);
Floors.ShowModal;
Floors.Free;
end;
procedure TDistricts.FormShow(Sender: TObject);
begin
PopulateDistrictBox;
ResizeTDBGridColumns;
//UpdateDepartments;
end;
procedure TDistricts.LBDistrictsClick(Sender: TObject);
var
SelectedItem : String;
DistNo: integer;
begin
SelectedItem := LBDistricts.Items[LBDistricts.ItemIndex];
With UQDistrictTBL do
begin
UQDistrictTBL.SQL.Text := 'SELECT * FROM DistrictTBL WHERE DistName = (:aSelectedItem)'; {// Union 39 School District}
UQDistrictTBL.ParamByName('aSelectedItem').AsString := SelectedItem;
UQDistrictTBL.Open;
end;
DistNo := UQDistrictTBL.FieldbyName('DistIDNo').AsInteger;
With UQDistLocationTBL do
begin
UQDistLocationTBL.SQL.Text := 'SELECT * FROM DistLocationTBL where DistIDNo = (:idNo)'; //+IntToStr(DistNo);
UQDistLocationTBL.ParamByName('idNo').AsString := IntToStr(DistNo);
UQDistLocationTBL.Open;
end;
UpdateDepartments;
end;
Procedure TDistricts.PopulateDistrictBox;
begin
UQDistrictTBL.First;
while not UQDistrictTBL.EOF do
begin
LBDistricts.Items.Add(UQDistrictTBL.FieldValues['DistName']);
UQDistrictTBL.Next;
end;
end;
procedure TDistricts.ResizeTDBGridColumns;
var
i: integer;
UQObject: TUniQuery;
TheGrid: TDBGrid;
TheWindow: TForm;
begin
TheWindow := Districts;
for i := 0 to Districts.ComponentCount - 1 do
begin
if Districts.Components[i] is TDBGrid then
begin
TheGrid := (Districts.Components[i])as TDBGrid;
//if TheGrid.DataSource.DataSet is TUniQuery then
UQObject := TUniQuery(TheGrid.DataSource.dataset);
ResizeTheGrid(UQObject, TheGrid, TheWindow);
end;
end;
end;
procedure TDistricts.UQDistLocationTBLAfterScroll(DataSet: TDataSet);
begin
UpdateDepartments;
end;
procedure TDistricts.UpdateDepartments;
var
SelectedItem : String;
DistNo: integer;
begin
if LBDistricts.ItemIndex >= 0 then
begin
SelectedItem := LBDistricts.Items[LBDistricts.ItemIndex];
With UQDistrictTBL do
begin
UQDistrictTBL.SQL.Text := 'SELECT * FROM DistrictTBL WHERE DistName = (:aSelectedItem)';
UQDistrictTBL.ParamByName('aSelectedItem').AsString := SelectedItem;
UQDistrictTBL.Open;
end;
DistNo := UQDistrictTBL.FieldbyName('DistIDNo').AsInteger;
With UQDistDeptTBL do
begin
UQDistDeptTBL.SQL.Text := 'SELECT * FROM UQDistDeptTBL where DistIDNo = (:idNo)';
UQDistDeptTBL.ParamByName('idNo').AsString := IntToStr(DistNo);
UQDistDeptTBL.Open;
end;
UQDistDeptTBL.First;
if UQDistDeptTBL.EOF then
begin
LBDistDept.Items.Add('No Departments Defined');
end
else
begin
while NOT UQDistDeptTBL.EOF do
begin
LBDistDept.Items.Add(UQDistDeptTBL.FieldValues['DistDeptName']);
UQDistDeptTBL.Next;
end;
end;
end;
{if LBDistricts.ItemIndex > -1 then
begin
SelectedItem := LBDistricts.Items[LBDistricts.ItemIndex];
With UQDistrictTBL do
begin
UQDistrictTBL.SQL.Text := 'SELECT * FROM DistrictTBL WHERE DistName = (:aSelectedItem)'; // Union 39 School District
UQDistrictTBL.ParamByName('aSelectedItem').AsString := SelectedItem;
UQDistrictTBL.Open;
end;
DistNo := UQDistrictTBL.FieldbyName('DistIDNo').AsInteger;
With UQDistDeptTBL do
begin
UQDistDeptTBL.SQL.Text := 'SELECT * FROM UQDistDeptTBL where DistIDNo = (:idNo)'; //+IntToStr(DistNo);
UQDistDeptTBL.ParamByName('idNo').AsString := IntToStr(DistNo);
UQDistDeptTBL.Open;
end;
UQDistDeptTBL.First;
if UQDistDeptTBL.EOF then
begin
LBDistDept.Items.Add('No Departments Defined');
end
else
begin
while NOT UQDistDeptTBL.EOF do
begin
LBDistDept.Items.Add(UQDistDeptTBL.FieldValues['DistDeptName']);
UQDistDeptTBL.Next;
end;
end;
end
Else
begin
ShowMessage('No Districts present, Districts need to be defined.');
end;
//LBDistDept.Items.Add('No Departments Defined');}
end;
end.