I'm using dephi 2010, which is getting difficult with me about installing the ADOX components. So I was wondering if there is a way to create a .mdb file without the use of the ADOXCatalog.
-Thank you.
Yes, this can be done without using an ADOXCatalog.
Place a TAdoConnection and e.g. a TAdoCommand on a form or datamodule. Set the TAdoCommand's Connection property to the TAdoConnection.
Then, in the AdoConnection's ConnectionString builder, select Microsoft OLE DB Driver for ODBC. Then, follow the ODBC wizard to set up a new MDB database. As you follow that through you will be able to create a File DSN (unless you are running Delphi as adminstrator), select the Access Jet driver, specify the database path (making sure it is somewhere writeable) and name, and then the wizard presents you with a button to click to create the MDB file.
Although it is not in English, there is a video here
https://www.youtube.com/watch?v=E_2hrER9oho
which shows you exactly how to do this. The ODBC connection string wizard should give you the option to create a new datasource and present you with a list like this to choose from:
Set the TAdoCommand's CommandText to something like
create table ATable (AName TEXT(40))
and call its Execute method at r/time to create a one-column table.
Btw, you could equally well use a TAdoQuery instead of the TAdoCommand component using its Sql property instead of the TAdoCommand's CommandTextproperty, and you should be able to use any valid DDL statements to define the tables in the database.
Related
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.
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.
I have a TClientDataSet object that I've added to my form.
I've managed to define the fields through the object inspector. However, is there a way to define the data the TClientDataSet contains without doing it in code?
I've managed to do it by adding some AppendRecord statements to the ShowForm event; but I'd rather keep the definition of the TClientDataSet all in one place.
Prior to v10.2 (Seattle, Berlin, etc.), there were no facilities to do this.
You can store and load a file into the ClientDataSet or you can use the Assign Local Data (right click on the ClientDataSet) to load data from an existing source. However, you cannot append or edit the data from inside the IDE directly.
As of v10.2 (Tokyo) has recently added this as a feature.
I have a program in Delphi 2010 that uses a JET (mdb) database via ADO. I would like to be able to extract the definitions of some of the queries in the database and display them to the user. Is this possible either via SQL, some ADO interface, or by interrogating the database itself (I don't seem to have rights to MSysObjects).
Some of that information is available via ADOX calls. There is an overview of the api with some examples (unfortunately not in Delphi) on the MSDN website.
Basically what you will want to do is to is to import the ADOX type library, and then use the wrapper that is generated for you to access the underlying API. From there its as simple as navigating the hierarchy to get at the data you need.
You will need to access the specific View object, and from there get the command property.
Via DAO, it's pretty easy. You just extract the SQL property of each QueryDef. In DAO from within Access, that would be:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = DBEngine.OpenDatabase("[path/name of database]")
For Each qdf In db
Debug.Print qdf.SQL
Next qdf
Set qdf = Nothing
db.Close
Set db = Nothing
I don't know how to translate that, but I think it's the simplest method once you're comfortable with using DAO instead of ADOX.
I don't use ADO at all, but I'm guessing that it has a collection of views and the SQL property would work for SELECT queries. However, if you're interested in getting the SQL for all saved QueryDefs, you'd also need to look at the DML queries, so you'd have to look at the stored procedures. I would have to look up the syntax for that, but I'm pretty certain that's how you'd get to the information via ADO.