Topic: Beginner Questions

Hello,

I installed version 0.50 in Delphi 2010. I playing around with the components and did some reading in the help file. Not all is clear to me and I'm getting warning messages.

Questions:

- I'm creating the database with:

dbSQLite.CreateDatabase('SQLitePassTest.db3', dbtUnknown, UTF16);

Q1. Is dbtUnknown the correct type? Any other type is giving me a warning after the second time that I open the database: Error while loading data from database. The "SqlitePass_DbSettings" table is corrupted or was created using an older version of this component.
Q2. I'm using UTF16 because delphi 2010 uses this as default string type. Is this correct what I'm doing?

- I created a table using the following code, this works fine smile

  With TSqlitePassEngine.Create(dbSQLite) do
  begin
    Try
      OpenDatabase(dbSQLite.Database);
      ExecSQL('CREATE TABLE [tblFileMemory] ([Filename] TEXT  NULL, [Filesize] INTEGER  NULL,[Filedate] INTEGER  NULL)');
    Finally
      CloseDatabase;
      Free;
    End;
  End;

- I've placed a TSQLitePassDataset and set the SQL to

SELECT * FROM [tblFileMemory]

When I try to open the Dataset I get the following error: TSqlitePassDataset.InternalOpen : Cannot Open Dataset.
The database is connected (checked) and assigned using the database property of the TSQLitePassDataset component.
I can't get this simple Select statement to work. sad

Help appreciated,
Pascal

Re: Beginner Questions

NEW Info:

I'm creating the database with:

dbSQLite.CreateDatabase('SQLitePassTest.db3', dbtUnknown, UTF16);

Q1. Is dbtUnknown the correct type? Any other type is giving me a warning after the second time that I open the database: Error while loading data from database. The "SqlitePass_DbSettings" table is corrupted or was created using an older version of this component.

This error only occurs when I create the databse with UTF16. It works fine with UTF8

Q2. I'm using UTF16 because delphi 2010 uses this as default string type. Is this correct what I'm doing?

Suppose I create the database with UTF8 .. is this a problem because delphi 2010 strings are UTF16.

Re: Beginner Questions

Reason found:

- I've placed a TSQLitePassDataset and set the SQL to

SELECT * FROM [tblFileMemory]

When I try to open the Dataset I get the following error: TSqlitePassDataset.InternalOpen : Cannot Open Dataset.
The database is connected (checked) and assigned using the database property of the TSQLitePassDataset component.
I can't get this simple Select statement to work.

My own fault.  I had been playing with the Field Editor. Cleared all fields and now this is ok.

Regards,
Pascal

Re: Beginner Questions

Hi Pascal,

Thanks for trying the components.

I'm creating the database with:

dbSQLite.CreateDatabase('SQLitePassTest.db3', dbtUnknown, UTF16);

Q1. Is dbtUnknown the correct type? Any other type is giving me a warning after the second time that I open the database: Error while loading data from database. The "SqlitePass_DbSettings" table is corrupted or was created using an older version of this component.

This error only occurs when I create the databse with UTF16. It works fine with UTF8

I'm going to try your code, check this bug and  let you know soon.
By the way, you don't need to set the SQL statement for the TSqlitePassDataset component since it should be set automatically when you select a table or query via the datasetname property editor.


Q2. I'm using UTF16 because delphi 2010 uses this as default string type. Is this correct what I'm doing?

Suppose I create the database with UTF8 .. is this a problem because delphi 2010 strings are UTF16.

You are right, Delphi from 2009 uses UTF16 as default encoding for strings but it is not directly related to database encoding. An UTF8 or UTF16 database can be used with any Delphi or lazarus version.

Regards.
Luc

Re: Beginner Questions

Hi Luc,

By the way, you don't need to set the SQL statement for the TSqlitePassDataset component since it should be set automatically when you select a table or query via the datasetname property editor.

Thanks. At the moment I'm using the Delphi ClientDataSet as a Memory Dataset. I load it at startup and save it at close application. I want to replace with SQLite database and your components. Why your components:
- Active development
- Compatible Lazarus and Delphi
- Documentation
- (Really Nice) Source Code

At the moment I'm testing inserts and filters to see how fast the combination is.
- First test on a virtual xp machine, an average of 1000 records added in 8 seconds (8ms/record).

I'll be back (I'm sure) with other questions.

Regards,
Pascal

Last edited by pcoenen (2010-03-28 19:16:22)

Re: Beginner Questions


Q1. Is dbtUnknown the correct type? Any other type is giving me a warning after the second time that I open the database: Error while loading data from database. The "SqlitePass_DbSettings" table is corrupted or was created using an older version of this component

You'll find the CreateDatabase prototype below. If you have a look at the code source (SqlitePassDatabase.inc) you'll notice that only "dbtKexi" is used in the current implementation. So any other type should produce the same result.


function TSqlitePassDatabase.CreateDatabase(DbName: String; DbType: TSqlitePassDatabaseType;
                                            DbEncoding: TSqlitePassEncoding = UTF8; PageSize: TSqlitePassPageSize = 4096;
                                            AutoVacuum: TSqlitePassAutoVacuumType = 0): Boolean;

I have to fix the other bug "Error while loading data from database. The "SqlitePass_DbSettings" table is corrupted or was created using an older version of this component".

Does it also occure when you open the db for the 3rd, 4th... time etc... ?
As a quick fix you can try to set the database.datatypeOptions.LoadOptions to soManual or the other database.datatypeOptions.LoadOptions properties to false.


At the moment I'm testing inserts and filters to see how fast the combination is.
- First test on a virtual xp machine, an average of 1000 records added in 8 seconds (8ms/record).

The filters are quite fast, especially if you use a "InMemoryIndex" = property Dataset.IndexedBy or if the dataset is already sorted by one of the filter field. (let me know how fast compared with other datasets (I didn't test)).

Concerning insert or edit operations your speed result seems to be very slow compared with my own tests except if your records are very big. Be sure to use a transaction first (SqlitePassDatabase1.Engine.Transaction.Start and commit or rollback).

Regards
Luc

Re: Beginner Questions

Hi guys,

I need help for new project, i have a problem for my sql data base i cant stored some info that are needed in form of registration...

can please somebody help about this.

Thanks..

Re: Beginner Questions

very informative questions are shared in this post,..
very useful one,.. thanks guys

Re: Beginner Questions

hi Pascal,..
thanks for this nice posting its very nice and useful one for others,..

Re: Beginner Questions

yeah pascal's post was really useful to my project thanks a lot! smile

Re: Beginner Questions

I had used SQL Lite once and it's too tough for  me and i'm here to learn some techniques.

Re: Beginner Questions

I am newbie in this forum and say hello to all of you

Last edited by sheikhjee (2011-02-19 18:59:20)

Re: Beginner Questions

very informative questions are shared in this post,thankssss so muchh!

Re: Beginner Questions

Hello, everyone. I am new in here.But in this post,I can see so important question also post and can get answers too. I really love it.Always post that type topic.

Re: Beginner Questions

sironmocco wrote:

I had used SQL Lite once and it's too tough for  me and i'm here to learn some techniques.

I think so too .

Last edited by sutivnn (2011-03-02 07:09:22)

Re: Beginner Questions

thanks