Recent

Author Topic: n00b - ZMSQL - How do I initially create tables?  (Read 3542 times)

Knipfty

  • Full Member
  • ***
  • Posts: 230
n00b - ZMSQL - How do I initially create tables?
« on: April 23, 2012, 11:40:56 am »
Hi All,

It's been a little more than a decade since I've used Delphi and am trying to do a small project for a friend.  I've downloaded and installed Lazarus and ZMSQL as well.  I've got the shell of the program up.  I'm now trying to code the 1st table of the database called Lenders.txt.

1. Do I need to create the table by handle using something like notepad++?  Which means typing in the field names on the 1st line and perhaps filling in a second line with some data?  Or will ZMSQL create this table for me?

2. How do I read this table into ZMQueryDateSet object?  When I specify the table name I get errors.

3. Assuming that I actually get data showing up in a dbgrid object, what steps to I need to take to edit or insert data and post them back out to the table on disk?

Thanks in advance,

Scott

PS based on the time I spent using these tools this past weekend, I'm very much impressed.  It feels very much like I remember Delphi feeling.  Good job everyone!
32-bit Lazarus 1.0 FPC 2.6.0, 64-bit Win 7, Advantage DB 10.10

marsheng

  • New Member
  • *
  • Posts: 28
Re: n00b - ZMSQL - How do I initially create tables?
« Reply #1 on: April 23, 2012, 12:40:25 pm »
I'm also new so here is my take. (Also from Delphi 6)

I'm using MySQL

Drop and SQLconnection, SQLtransaction, SQLquery and DataSource onto you form or better still datamodule.

In the SQLConnection - you set the parameters to connect to your db. The db must be running as in the case of MySql


The SQLtransaction then connects to SQLConnection

From here, the SQLquery creates the table/data you require using the SQLTransaction. You need to specify an SQL statement in the Query to fetch your data.   My statement is SELECT * FROM members where members is a table in the DB.

The DS then connects the query results with your DBGrid or other forms.

Here is a video to get you started.

http://www.youtube.com/watch?v=pq2oCiJePHo

Took me a while but really pleased with the result.

You will have to learn some SQL language.

I use XAMPP to start and stop my SQL database and Heidi to edit the DB.

tatamata

  • Hero Member
  • *****
  • Posts: 732
    • ZMSQL - SQL enhanced in-memory database
Re: n00b - ZMSQL - How do I initially create tables?
« Reply #2 on: May 05, 2012, 12:23:15 pm »
Use FieldDefs property of Object inspector to define fields (columns).
Use either Open method (in case of a table) either QueryExecute method (in case of queries) to create dataset.

tatamata

  • Hero Member
  • *****
  • Posts: 732
    • ZMSQL - SQL enhanced in-memory database
Re: n00b - ZMSQL - How do I initially create tables?
« Reply #3 on: May 05, 2012, 12:25:36 pm »
You can also create Csv table in a spreadsheet or a text editor and load it into zmsql by LoadFromCsv method.

tatamata

  • Hero Member
  • *****
  • Posts: 732
    • ZMSQL - SQL enhanced in-memory database
Re: n00b - ZMSQL - How do I initially create tables?
« Reply #4 on: May 08, 2012, 08:37:01 pm »
You can also create Csv table in a spreadsheet or a text editor and load it into zmsql by LoadFromCsv method.
I think this is the easiest way .. ;D
The easiest yes, but the least flexible, because in that case zmsql will create fielddefs on the fly as string fields.
It would be better to define fieldefs first, to have proper data types.

 

TinyPortal © 2005-2018