Lazarus

Programming => Databases => Topic started by: Mi-Ki on January 30, 2023, 04:05:45 pm

Title: Component to sdf file - Microsoft SQL Server database
Post by: Mi-Ki on January 30, 2023, 04:05:45 pm
Hi.
I can't do much in lazarus.
Can you help me please?

I've bought a piece of software that stores its database in an .sdf file
How to open a Lazarus database?


Need to open a database and load a table VAZENI

Here's the database **://leteckaposta.cz/486686910
Thank you very much.
Title: Re: Component to access sdf database table
Post by: wp on January 30, 2023, 04:19:33 pm
There is a TSDFDataset. Go to "Package" > "Install/uninstall packages" and make sure that package SDFLaz is installed.

Cannot download your database file. Why don't you zip it and attach it to your post? (If it's too large remove some lines - sdf is a text file).
Title: Re: Component to access sdf database table
Post by: Mi-Ki on January 30, 2023, 04:50:45 pm
I'm sorry.
I almost deleted everything and has more tha 500 KB.
Title: Re: Component to access sdf database table
Post by: wp on January 30, 2023, 04:55:37 pm
No - this not the kind of SDF file that I mean since it is not a text file - forget my previous post. Which application did you use to write this file?

**s://filext.com/file-extension/SDF - Microsoft SQL Server Compact?
Title: Re: Component to access sdf database table
Post by: Mi-Ki on January 30, 2023, 05:07:14 pm
I bought the software that it stores in this file.
I opened the database in SDF Viewer 1.13.
**s://sdf-viewer.software.informer.com/St%C3%A1hnout/
**s://postimg.cc/c6dtkS5f

Can't Lazarus use for this file?   :(
Title: Re: Component to access sdf database table
Post by: wp on January 30, 2023, 05:56:05 pm
Can't Lazarus use for this file?   :(
I tried to set up a connection with MSSQLConnection but failed due to a missing dll. But wait a bit, I am not an expert with MSSQL, maybe somebody else knows a solution.
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Thaddy on January 30, 2023, 05:56:40 pm
https://fileinfo.com/extension/sdf

Which one?

Note the microsoft version is deprecated for 10 years....
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Mi-Ki on January 30, 2023, 06:02:48 pm
Thaddy - I know, but we have the software that uses it.
They need to add data.
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Sieben on January 30, 2023, 06:11:55 pm
This here site (http://www.ilovefreesoftware.com/02/featured/free-sdf-viewer-software-view-edit-sdf-database-files.html) lists 4 free tools to view and even edit MS SQL Server CE *.sdf files. Since it dates from 2017 these might still be available.

Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Thaddy on January 30, 2023, 06:13:31 pm
Better to convert the lot to sqlite, ahum, maybe firebird, or standard database format.
In that case your bought library should help over an e.g. odbc connection and on a microsoft system.
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Thaddy on January 30, 2023, 06:14:45 pm
This here site (http://**://**://**://**://**://**://**://**s://www.ilovefreesoftware.com/02/featured/free-sdf-viewer-software-view-edit-sdf-database-files.html) lists 4 free tools to view and even edit *.sdf files. Since it dates from 2017 these might still be available.
sdf files lead to confusion because the extension name is not very carefully chosen. Such files are likely to represent different things.

More or less like the imaginary Thaddy's Xenophobic Trauma format.. (txt extension would be nice....)  %)  :o
And no, no driver for that. Maybe you can read it but I won't let you!! Go away...  O:-)
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Mi-Ki on January 30, 2023, 06:50:33 pm
What is this?
https://www.youtube.com/watch?v=pq2oCiJePHo
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Thaddy on January 30, 2023, 06:58:44 pm
What is this?
**s://www.youtube.com/watch?v=pq2oCiJePHo

NOT the Microsoft format but the Standard Database Format.... You really do not grasp it, do you?

YOUR SDF is Microsoft specific. SDF is a text based format for the normal people.

Also note the dead giveaway: MSSQL is never mentioned.
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Mi-Ki on January 30, 2023, 07:07:43 pm
You confuse the truth, I don't understand. I've never done with the database before.
So is it unsolvable through Lazarus?
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: paweld on January 30, 2023, 07:40:51 pm
Devart's SDAC component suite has the ability to connect to SQL Server Compact - these are paid components:  https://www.devart.com/sdac/
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: TRon on January 31, 2023, 12:13:11 am
You confuse the truth,
That seem to happen when meddling with things that one has no experience with  :)

Quote
I don't understand. I've never done with the database before.
Tbh that was a bit obvious as you also linked to a youtube video that does absolutely nothing with SDF / SQL server compact.

The video only shows that Lazarus is capable of developing database applications in this particular video by connecting to a firebird database.

You wrote:
I've bought a piece of software that stores its database in an .sdf file
You seem to have purchased software that stores its data in a proprietary database format.

According to the wiki the origin of that database format is EOL and has been so for many years (https://en.wikipedia.org/wiki/SQL_Server_Compact).

Try to see if your software is able to store/save/export the database to another format that /is/ supported by Free Pascal/Lazarus and repeat the quest(ion).

Quote
So is it unsolvable through Lazarus?
See paweld's answer.

Personally I would not bother so would advise against it (but I have not a clue about your restrictions/freedoms).
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: paweld on January 31, 2023, 09:29:32 am
You can also connect via OleDB, using the ComObj unit.
An example is attached.
The system must have Microsoft SQL Server Compact 4 installed: https://www.microsoft.com/en-us/download/details.aspx?id=30709
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Mi-Ki on January 31, 2023, 10:34:16 am
paweld - Thank you very much, it works.  :D

Need to work with the table VAZENI
There is Stringgrid.
When I add another line, how to save?
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: paweld on January 31, 2023, 03:01:46 pm
I have expanded to include the ability to add records - attached.

Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: Mi-Ki on January 31, 2023, 04:59:15 pm
I have expanded to include the ability to add records - attached.

Thank you very much. :)
Title: Re: Component to sdf file - Microsoft SQL Server database
Post by: paweld on January 31, 2023, 08:00:20 pm
In the previous version, there is a bug related to the formatting of the date when adding a record - the database accepts the format yyyy-mm-dd, so as in the system was different it threw an error. Attached is the new version, and below is just the modified function:
Code: Pascal  [Select][+][-]
  1. function TForm2.ValueToSql(idx: Integer): String;
  2. var
  3.   cn: ShortString;
  4.   i, j: Integer;
  5.   fs: TFormatSettings;
  6. begin
  7.   fs.DecimalSeparator := '.';
  8.   fs.ShortDateFormat := 'yyyy/mm/dd';
  9.   fs.DateSeparator := '-';
  10.   fs.LongTimeFormat := 'hh:nn:ss';
  11.   fs.TimeSeparator := ':';
  12.   Result := '';
  13.   case Form1.tablestruct[idx]._type of
  14.     'int', 'bigint', 'numeric', 'decimal', 'float': cn := 'TFloatSpinEdit';
  15.     'varchar', 'char', 'nvarchar', 'nchar': cn := 'TEdit';
  16.     'text', 'ntext': cn := 'TMemo';
  17.     'date', 'time', 'datetime': cn := 'TDateTimePicker';
  18.   end;
  19.   j := -1;
  20.   for i := 0 to Panel1.ComponentCount - 1 do
  21.   begin
  22.     if Panel1.Components[i].ClassName = cn then
  23.     begin
  24.       if Panel1.Components[i].Tag = idx then
  25.       begin
  26.         j := i;
  27.         break;
  28.       end;
  29.     end;
  30.   end;
  31.   case Form1.tablestruct[idx]._type of
  32.     'int', 'bigint', 'numeric', 'decimal', 'float': Result := FormatFloat('0.######', TFloatSpinEdit(Panel1.Components[j]).Value, fs);
  33.     'varchar', 'char', 'nvarchar', 'nchar': Result := '''' + StringReplace(TEdit(Panel1.Components[j]).Text, '''', '''''', [rfReplaceAll]) + '''';
  34.     'text', 'ntext': Result := '''' + StringReplace(TMemo(Panel1.Components[j]).Lines.Text, '''', '''''', [rfReplaceAll]) + '''';
  35.     'date': Result := '''' + DateToStr(TDateTimePicker(Panel1.Components[j]).Date, fs) + '''';
  36.     'time': Result := '''' + TimeToStr(TDateTimePicker(Panel1.Components[j]).Time, fs) + '''';
  37.     'datetime': Result := '''' + DateTimeToStr(TDateTimePicker(Panel1.Components[j]).DateTime, fs) + '''';
  38.   end;
  39. end;    
  40.  
TinyPortal © 2005-2018