Reputation: 3033
This question does not have any code, but I must ask for help because I can not resolve this issue. I searched SO for similar questions and found several whose answers did not help me resolve this problem.
I was having trouble creating a TClientDataSet project with my main development pc, so I tried creating a project on my Windows Tablet. Both pcs are running windows 8.1 with DelphiXE4.
I added a TClientDataSet, a TDataSource and a TDatasetProvider to a new project. I added 3 fields in FieldDefs at design time, then selected CreateDataset from the popupmenu of TClientDataSet. The dataset was created just fine so I continued and added a TDBGrid, TDBNavigator, entered some data and saved the TClientDataSet to a file.
The small demo app worked very well with no problems. I can view and enter data, save to a file and load from a file, so I zipped up the project and copied it to my development pc. I tried running the demo but when LoadFromFile is called a Missing Data provider exception occurs. I tried deleting the xml file and then tried to recreate the file using the same process I used on the tablet pc and I got the Missing Data provider message again.
In following up on the SO answers I added MidasLib to uses as recommended in several SO answers but that failed to resolve the problem. I searched for Midas.DLL and found them to be present.
My question: Is it possible that dsnap180.bpl is corrupt or is something else missing from my development pc? My objective is to be able to create and open a TClientDataset on my development pc. Any suggestions or guidance is appreciated.
EDIT Kens Demo
Pas
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids,
Vcl.DBGrids, Data.DB, Datasnap.DBClient;
type
TForm1 = class(TForm)
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientDataSet1.FieldDefs.Add('Collection', ftString, 50);
ClientDataSet1.FieldDefs.Add('Filename', ftString, 200);
ClientDataSet1.CreateDataSet;
ClientDataSet1.Active := True;
ClientDataSet1.AppendRecord(['General', 'D:\Images\Test.jpg']);
ClientDataSet1.AppendRecord(['General', 'D:\Images\BeachBall.bmp']);
end;
end.
DFM
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 299
ClientWidth = 635
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 635
Height = 299
Align = alClient
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object ClientDataSet1: TClientDataSet
Aggregates = <>
Params = <>
Left = 71
Top = 35
end
object DataSource1: TDataSource
DataSet = ClientDataSet1
Left = 116
Top = 34
end
end
DPR program Project1;
uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Upvotes: 1
Views: 8799
Reputation: 31
Issue looks like 32 bit/64 bit windows target platform. It would work fine if you target 64 bit. It worked just fine for me. Otherwise you may need to verify if you are using 32 bit midas dll
Upvotes: 0
Reputation: 125610
The following works for me perfectly well:
Drop a TClientDataSet
, TDataSource
, and TDBGrid
on a blank form. Connect the grid to the datasource, and the datasource to the clientdataset. (Note no TDataSetProvider
.)
Add the following code to the form's FormCreate
event:
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientDataSet1.FieldDefs.Add('FirstName', ftString, 20);
ClientDataSet1.FieldDefs.Add('LastName', ftString, 20);
ClientDataSet1.CreateDataSet;
ClientDataSet1.Active := True;
ClientDataSet1.AppendRecord(['John', 'Smith']);
ClientDataSet1.AppendRecord(['Jane', 'Doe']);
end;
Run the application:
Adding MidasLib
to the uses clause removes the need to distribute Midas.dll with your application, but it does not affect the dataset provider at all.
Upvotes: 5