A 'First' for xBase - code creating a full SQL database !?

Public forum to share code snippets, screen shorts, experiences, etc.
Post Reply
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

A 'First' for xBase - code creating a full SQL database !?

Post by Phil Hepburn »

Hi Robert, and all guys,

This is just a short post to introduce the fact that yesterday I managed to do in xBase what I had successfully done some six years ago in C# - that is have the code of my X# app create a new SQL database with multiple Tables, and then immediately populate those tables with test data. Everything done from code and in VS - because I am using WPF for a small form.

I will post much more here as I still need to do further tidying and improving work today. I am also writing the eNotes for Cologne as I am doing the development, so this takes a bit extra time.

It is my intent to try and post a link from a shared 'OneDrive' folder of mine, so that you can download and run the code yourselves, on your PC. As long as you have a "C:Temp" folder on your system.

Yes, the L2S (LINQ to SQL)app currently drops and recreates the database each time it is run, adding the test data items just afterwards. Its all quite easy to do, not difficult to understand, BUT, like a lot of data stuff is a bit tricky to get right ;-0) Many little places where it can go wrong!

Attached / below is the result of this current test app in Management Studio - three tables Customer, Invoice, Product. I have included a shot of the Customer test data in image '_02'.
PearlsCF_L2S_01.jpg
PearlsCF_L2S_01.jpg (51.67 KiB) Viewed 582 times
PearlsCF_L2S_02.jpg
PearlsCF_L2S_02.jpg (102.04 KiB) Viewed 582 times
Hope this interests a few of you guys - this is all part of going to Entity Framework - L2S is good practise for EF6/7 apps.

Regards,
Phil.
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

A 'First' for xBase - code creating a full SQL database !?

Post by wriedmann »

Hi Phil,

actually I have finished something also for Firebird - my choice for a SQL database because it is free, powerful and available on Linux and Windows - even a "all-contained" solution for a single user database is available, completely configuration free.
My code even checks the current table structure and adds/modifies missing/changed fields.

Unfortunately I had to write code specific to Firebird....

If someone is interested, I can make a working sample.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

A 'First' for xBase - code creating a full SQL database !?

Post by Phil Hepburn »

Hi Wolfgang,

Sounds good, do you use LINQ at all in your solution ?

And do you use X# in your coding for this ?

I am not familiar with Firebird - what exactly is it ?

The main point I was making was that with ONLY X# code I could design and create the SQL database, as well as seeding it with suitable test data. And that LINQ was key to doing this.

Good Luck and speak soon,
Phil.
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

A 'First' for xBase - code creating a full SQL database !?

Post by wriedmann »

Hi Phil,
Sounds good, do you use LINQ at all in your solution ?
no, plain SQL.
And do you use X# in your coding for this ?
yes, of course! Since Robert has added some new language features to X# specially for my needs, I have removed all C# code.
I am not familiar with Firebird - what exactly is it ?
Firebird is a full blown opensource SQL server. It is a descendand of Borlands Interbase.

firebirdsql.org

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

A 'First' for xBase - code creating a full SQL database !?

Post by Phil Hepburn »

Hi Wolfgang (and all),

Just so that the other guys are aware, the reason I posted the original message about a 'first for X#' was not the connection to the SQL database itself - we could do that with ADO.NET in Vulcan over 7 years ago - it was the fact that all the communication with the SQL database 'engine' was done using compiled X# code. From the very creation of the DB through to its Table creation and population, and subsequent data retrieval querying.

Sending a character string through to the DB engine (for us) is what the technology is all about - any T-SQL statements sent to the DB Server have all been composed 'under-the-hood' by the Microsoft LINQ to SQL (L2S) technology, and that is VERY clever.

So all our stuff has the benefits of compiler checking, and us using data types which are .NET types, etc., etc.. Effectively, the SQL engine is hidden from view to us developers. All we need is a certain level of understanding as to how the SQL Server works.

I hope this makes some sense to most folks ;-0)

And don't forget it, we are really aiming to get to 'LINQ to Entities' with X# quite soon ;-0) With EF6/7 we can do more business like 'stuff' (Entities) and also the back-end data source can be other than MS SQL Server.

Regards,
Phil.
User avatar
orangesocks
Posts: 40
Joined: Thu Nov 12, 2015 2:41 pm

A 'First' for xBase - code creating a full SQL database !?

Post by orangesocks »

Hi Wolfgang,

I'm in the middle of migrating my DBF database to SQL.
I would be very interested in seeing a sample.
Thank you.

Giuseppe
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

A 'First' for xBase - code creating a full SQL database !?

Post by wriedmann »

Hi Giuseppe,

I'll put together a small sample the next week.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply