when I use a TSimpleDataSet, the IDE cannot allow me to expand Connection and DataSet property.
See the image below. I don't have the arrow to expand properties but only on Connection and DataSet.
Please give me support!
Your project needs to contain a TSqlConnection component before you can set the Connection property of a TSimpleDataSet.
Do this:
Start a new VCL project.
Add a TSqlConnection and a TSqlQuery to the form.
Configure the TSqlConnection to access a Sqlite database on your system.
Set the SqlConnection of SqlQuery1 to SqlConnection1.
Now ...
Add a TSimpleDataSet to the form.
Set the Connection property of SimpleDataSet1 to SqlConnection1. This answers your first point.
Notice that you still can't change the DataSet property of SimpleDataSet1. That's working as designed, because it is only supposed to use this internally-created dataset.
Open the DataSet property of SimpleDataSet1 and set its CommandText property to do a SELECT query against one of the tables in the Sqlite databaase.
Set SimpleDataSet1.DataSet.Active to True. That'h how you use TSimpleDataSet's DataSet property.
Next, see https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TSimpleDataSet and https://docwiki.embarcadero.com/Libraries/Sydney/en/SimpleDS.TSimpleDataSet.
Related
I'm trying to load about 500k+ data linked to an Oracle DB on my TcxGrid, I want to make the process faster using the GridView "GridMode" property, but I need to do that using a TSQLQuery (DBExpress Component) and it just doesn't work, Gridmode seems inoperable (doesn't load data faster on the Grid, doesn't load custom quantity of records using the "BufferCount" property, etc.)
Here I created a TSQLQuery component and used a query script for my 500k table (for performance purposes I just got 500 values but I need to load 500k+):
TSQLQuery
When I link the TSQLDataSet to the Grid and activate the TSQLQuery it shows all the records from the query, even if the GridMode is TRUE and the GridModeBufferCount is 5
GridWithTSQLQuery
On the other hand, when I use a TQuery, the GridMode just works properly, in this case I had to open SQL Explorer, make the connection and assign that connection to the TQuery DataBase property:
SQLExplorer
Here I show my TQuery with the values mentioned before:
TQuery
And when I activate my TQuery.. voilá:
GridWithTQuery
What I'm doing wrong? or do I need to do more things on my TSQLQuery besides linking it to my dataset and then linking the dataset to the grid?
It's impossible that a very old Tquery can do this and not a newer dbExpress component
Thank you so much guys
OK, so I am a self taught basic coder by watching videos on how to do basic coding with Delphi and i have successfully created an application where i use a text file for a login form with usernames and passwords being checked (with a lot of help from videos). How can i use Microsoft Access for the login for the username and a password? I struggle to find a video on how it works. I found a video telling me how to connect ado tables and connections, but i am struggling with the login. Any help would be appreciated.
If you can follow the video about Ado tables, all you are missing is how to configure the TAdoConnection you use to connect to the database. Assuming you've got the project set up:
In the IDE, click your TAdoConnection - usually it would be called AdoConnection1 by default.
In the Object Inspector, click AdoConnection1's ConnectionString property.
In the Data Link properties pop-up, select the MS Office 12.0 Access Database Engine OLE DBProvider (the version number may be different on your system), then click `Next'.
On the next tab, in item 1, enter your database's exact name and extension, including the full path to it.
In item 2, enter the User name
Then click Test connection. Assuming you get Test connection succeeded, you're done.
Try that and see how you get on.
Btw, very occasionally you may come across Delphi Ado projects that don't have a TAdoConnection; in that case, you configure the connection of the TAdoDataSet component (e.g. a TAdoTable) by the above method.
If you would prefer to start with a blank form and set it up from scratch yourself, do the following before the above steps:
Place the followinng components on the form: a TAdoConnection; a TAdoTable; a TDataSource (on the Data Access tab of the Component Palette); a TDBGrid and a TDBNavigator (both on the Data controls tab. Then wire them up as follows:
In the Object Inspector set the DataSource properties of DBNavigator1 and DBGrid1 to DataSource1
Set DataSource1's DataSet property to AdoTable1
Set AdoTable1's Connection property to AdoConnection1
Then, configure AdoConnection1 as detailed above.
Finally
Set AdoTable1's TableName property to the name of a table in your database, thn set its Active property to True.
Compile and run.
Once you've got it working, set AdoTable1's Active property to False and instead set it to open in Form1's FormCreate event. You can also set AdoConnection1's LoginPrompt to False if you prefer.
How can i set the whole table of a database to show in my delphi form? Using TDBGrid i presume; but when I configure the data source (connected to a query) I receive an error message about it being Unidirectional. I've heard about a Clientdataset but that didnt seem to work. Could i have some clear instructions on how to do this please? Thank you in advance, Toby.
You say you are using TSQLQuery. This is one of the dbExpress components which are designed to be Unidirectional only (except the TSimpleDataSet). You either have to connect the TSQLQuery to a TDataSetProvider and TClientDataSet or change your query component to one that will buffer the data locally.
To use TDataSetProvider and TClientDataSet:
Set the DataSet property of TDataSetProvider to the SQLQuery.
Set the ProviderName property of the TClientDataSet to the DataSetProvider.
When the ClientDataset is opened, it will contain the data from your SQLQuery.
Set the DataSet Property of your TDataSource to the ClientDataset so the data can be displayed in your DBGrid.
Since you appear to be new to using databases with Delphi, I would recommend you use a different query component, because using the TDataSetProvider and TClientDataSet can be complicated. I suggest
TSimpleDatSet in dbExpress,
TADOQUery or TADODataset in dbGo,
TQuery in BDE (not recommended),
TFDQuery in FireDAC, or
other third party query components.
I am trying to create an additional field that is NOT ReadOnly at runtime in Delphi. I have a TADOQuery with SQL on the lines of
SELECT *,CAST(0 AS BIT) AS CheckField FROM MyTable WHERE KeyField = :KeyValue
This links through a TDatasetProvider to a TClientDatset.
My issue is the resulting field in the TClientDataset ends up as ReadOnly.
The TClientDataset is created at design time to link into grids etc. The other components are created at runtime in a separate object.
I have had a similar setup working , but with everything created at design time. I resolve this problem by creating persistent fields on the TADOQuery component and setting the CheckField's ReadOnly property to False prior to opening the TClientDatset. I am unsure as to how to do this at runtime given the field component doesn't exist until I have opened the ClientDatset and by then it's too late to set it's readonly property!
The problem is the CAST().
The dataset doesn't analyze what the underlying field might be that's being CAST; it just knows that it's a function result that is placed into the column, and you can't edit a function result.
You could just SELECT *, 0 AS CheckField, and then set a validation on the resulting field to restrict the values to 0 and 1.
I am using these components:
UniDac for connection to mysql database
DevExpress for QuantumGrid
IDE:
Embarcadero Rad Studio XE2
I have a cxGrid component with one level and a cxGrid1DBTableView specified as the level's View. I can get data from my database and edit it in the grid. I want to add a column that is not in the bound DataSet. When I specify the Column properties value as CheckBox I can see the column but I can't change the value from unchecked to checked by clicking it. The field doesn't have a DataBinding assigned to it. I tried other types of Properties but all are the same I cant change the row value in the grid.
I've been searching for a way to fix this for couple of days, so im hoping you guys can help me.
Are you trying to add a checkbox item that does not have a database field behind it? I have this on one of my forms.
In addition to setting the Properties to "Checkbox" you need to set the DataBinding -> ValueType to "Boolean". The DataBinding->FieldName can be left blank.
To access the values or change their defaults you can use the DataController like this:
View.DataController.Values[i, CheckBoxFieldIndex] := true;
In addition you need to set
DataController.DataModeController.SmartRefresh := true;
To set that option you will also need a KeyField defined for the Controller (DataController.KeyFieldNames)
Setting the SmartRefresh to true will prevent the grid from trying to get an updated value from the underlying dataset. You need to prevent the refresh or the value for the non-bound column will be set back to Null. This comes with some restriction on how you update your dataset. Any changes made to the data in code will not be reflected by the grid unless you explicitly refresh the grid.
You also have to fill the field View.DataController.KeyFieldNames with one of the datasets fields. At least I need it in Delphi 7.