* * *

Author Topic: Trying to open self-created SQLite db, and getting DBGrid ..errors. Help? >.>  (Read 304 times)

Firewrath

  • New member
  • *
  • Posts: 11
Note: Due to Forum size limits, 'sqlite3.dll' was removed from the project file. I also had to rename 'TestAccount.sql' to '.txt'.

So I've been learning SQL and how to use it with Lazarus in hopes to make my own personal accounting software.
Mainly just for fun and learning. So nothing I plan on releasing.
(I'm no accountant, so watching my own spending is fine, cause if I screw up then its only me. :P)

So I typed up my own sql file for spending and such, then saved it as a database using SQLite Tools and used the attached project to view the file and ...it turned out kind of like the attached pic.

Now, i'll admit the attached project code is a little bit of a mishmash of stuff I pulled off the net/forms and such, but it opens other SQLite database files that I had for testing (Like Chinook and a D&D3.5 SRD Database).
Then when I went to open mine, ...well, It doesn't really work.

So, I created this TestAccount.db and viewed it with the attached project and it does the same thing.
TestAccount.db was made using the TestAccount.sql file attached below and saved as a Database with SQLite Tools.
A program called SQLite Control Center also opened my TestAccount.db just fine and using the attached sql file in SQLite Control Center to create a Database gives the same results.

So can someone tell me where I'm screwing this up?
or point me to something that'll help.
...Though I'll say that finding tutorials for SQLite and Lazarus/Free Pascal is ...difficult. So I may have missed something.
(Plus limited internet doesn't help...)

...oops, forgot: I'm on WinXP with Lazarus 1.6.4
« Last Edit: October 24, 2018, 10:16:11 pm by Firewrath »
Sorry. I currently don't have Internet Access. So my replies might take a week. -_-

gorkamorka

  • New member
  • *
  • Posts: 8
Hello !

Please try this  ;


change that line

create table TestAccount (id integer primary key, Date DATETIME, Desc text, Type text, Amount REAL, Notes text);

with this

CREATE TABLE TestAccount (
    id     INTEGER  PRIMARY KEY,
    Date   DATETIME,
    [Desc] STRING,
    Type   STRING,
    Amount REAL,
    Notes  STRING
);

Changing "text" type to "string" should give you attached result.

chrnobel

  • Full Member
  • ***
  • Posts: 225
Changing "text" type to "string" should give you attached result.
Actually, in my experience, it is best to use Varchar.

SQLite does not internally use Varchar, as records always are stored as text, but the definition is read by the database driver, so the program can interpret the data correctly.

So typically use Varchar(20) eg - this ensures that the columns in dbGrid does not get to wide, and actually SQLite is capable of storing strings longer than 20 characters wide, despite the 20 character definition.

Thaddy

  • Hero Member
  • *****
  • Posts: 7087
Note: Due to Forum size limits, 'sqlite3.dll' was removed from the project file. I also had to rename 'TestAccount.sql' to '.txt'.
You should never include binaries, not exes, not dll's, in attachments. Just sourcecode and resources needed to reproduce a problem.
You may include a link to executables. 
Small executables can be zipped, but wait for a request to do so: we need sourcecode to help you, not the binary result.
« Last Edit: October 25, 2018, 06:06:47 pm by Thaddy »
inline variables like in D10.3 are a bit like Brexit: if you are given the wrong information it sounds like a good idea. Every kid loves candy, but it makes you fat and your teeth will disappear.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus