NetDbExplorer : Demo for mj10777.DataBase Class






1.04/5 (11 votes)
Jan 5, 2004
6 min read

37700

1166
The use of mj10777.DataBase to Connect, Create (Database/Table), Read and Fill Tables, Update, Insert and Delete Records and show results in a TreeView / ListView Application.
I would like to submit my mj10777.DataBase with the NetDbExplorer as a Demo Example
mj10777.DataBase is a Class Collection for Database support under .NET Framework / .Net Framework.Compact
For private use your are free to do what you want with this Source, otherwise please note the Copyright notice and the end of this article.
The Source is highly Documentated, therefore this Article will remain short (see note on Documentation below)
NetDbExplorer_src.zip has 2 Zips inside, one for PC and one for Compact
NetDbExplorer_demo.zip has a PC Exe for free use
(Compact Exe is included in NetDbExplorer_src.zip)
Beware : I used a different directory for my Projects (Microsoft.Net and Microsoft.Net.Compact) - the directory inside the Zip have the same name !
This may also be considered as a way to write a Project that will run on both Platforms.
The Directory \DataBase\*.* from the PC Project can be (and was) copied (often) to the Compact Project and back (also)
A precompiler directive "COMPACT" is used in the Compact project Configuration to write Code for both Platforms in one .cs file with no warnings/errors from the compiler. (not true of course if you forget to set ....)
See Documentation on how to do this.
DataBase Class
Dissapointment was not the word I used, when I saw what Visual Studio Designer 2002 did with my Access Lotto Database.
Having written a Class (with George Tasker - Remstar) for wxWindows (http://www.wxwindows.org/) to analyse a Database with Table/Field Structures (wxDB/wxTable), I was unhappy about the mess Visual Studio made and all the work that had to be done with each Table.
However after a carefull study of DataSet / DataTable / DataView and DataRow I was very pleased with what had been achived in .NET Framework.The result and use is very similar to what we did under ODBC with wxWindows (I wrote the wxWindows/demos/dbbrowse, that does the same thing as NetDbExplorer).
Still all these Connection Strings and Engine Types had to be worked out, since a friend of mine did not know if he wanted to switch from dBase to Access or Excel. The result was my first NET Project called DbBrowser (Google : Searched the web for dbbrowser. Results 1 - 10 of about 4,470. Search took 0.17 seconds) which put all the Connection Strings / Engine Type's in one Class.
At first I wrote a class each for Odbc and OleDb since Odbc was not really needed.
Then came Visual Studio 2003 and SqlCe for Compact and with it the beauty of NTEXT as apposed to VARCHAR (at least UNSIGNEDTINYINT is now TINYINT), so I wrote an extra Class for this.
Being feed up with all of this, I started write a Card Playing logic for Games and started to learn the Documenting System as I went along.
The result of this was my Article about Language Support also published here just before Christmas.
The next move was of course to Document the Odbc/OleDb/SqlCe Classes - but to do this 3 times was out of the question.
It was much easier to put them all togeather in one DataBase.cs that used a "ServerType" Parameter (Odbc,OleDb,SqlCe/SqlServer) and compile on both PC and Compact Platforms (Documenting everything while doing this). 4 hours before Silvester / New Year everything was compleated and worked. What I did then you can imagin.
The major goals of this Class are :
the simple use of this Class to Connect, Create (Database/Table), Read and Fill Tables, Update, Insert and Delete Records.
OleDb and SqlCe does not have a direct way to read all Tables found in the DataSet.
Using "SELECT * FROM INFORMATION_SCHEMA.TABLES" this class will collect the names of the existing Tables on Connection and fill the DataSet with these Tables when read :
private const string s_DataSetNamespace = "MainFrame"; private const string s_mj10777_Company = "mj10777.de.eu"; private const string s_mj10777_Folder = "file://My/ Documents\\"+s_mj10777_Company+"\\"; private const string s_DocumentFolder = s_mj10777_Folder+s_DataSetNamespace+"\\"; private int ip_EngineType = 5; // 5= Access ;ServerType=1 : OleDb private DataBase db_DataBase = null; public FormMainFrame() { InitializeComponent(); i_Language = 1; // Call Method to create sa_CreateTables, if needed db_DataBase = new(DataBases_DocumentFolder,s_DataSetNamespace,ip_EngineType,1,ip_Language); dset_MainFrame = db_Table.OnReadDBtoDataSet(); // Connects to Database and Disconnectd after reading //DataSet now has all Tables found in the DataBase // Save Access Database as Excel File db_Table.i_EngineType = 24; // (Excel 8.0 and 9.0 Workbooks) // Connects to Database and Disconnectd after writing db_Table.OnCreateDBfromDataSet(dset_MainFrame,true); } // public FormMainFrame()
The need to test this for PC and Compact lead to the creation of :
NetDbExplorer
The reason for the chosen name is : Goggle (05.01.2004) : Your search - NetDbExplorer - did not match any documents.
The major Goals of this Demo are :
- testing mj10777.DataBase.DataBase Class
- tool for analysing Databases on PC and Compact for Framework Development (thus System.String, System.Int32 etc)
The major Function of this Demo are :
- read and writing Databases without User/Password protection
- tool to Change Dataset / Table / Field names
Documentation
The .cs file's are highly Documented for the use of Programers which wish to use these Classes.
An nDoc Configuration File and the resulting Help file has been included in the Zip files.
Each Class has a full description in the Class Overview of what was indended to achive.
Here there are many References to the Class Methods with Code examples of the use of these Classes and the general use of DataSet, DataTable, DataView and DataRow.
The idea was to generate one Help file with all the collected Information pertaining to ODBC, OleDb, SqlCe and certin programming technics developed in the last 6 Months.
Also certain aspects of the .NET Framework that I find interesting have been build in to this Help file.
I have attemted to make full use of the XML-Documentation offered by the Visual-Studio to build one source of what, where and how things are done (Not to mention : "what was I thinking abut when I did that?").
Known problems, things that do not work and hopes for the future development are also noted.
Support
I am quite willing to support this Class further where needed.
Please send me an EMail if something does not work and needs fixing (with a Sample of the Database where possible)
Please send me an EMail if would like Functionality to be added
Condition for free suport is of course that this is for private use (See Copywrite below)
No support can be given if the Copyright of other Products are not respected!.
If somebody changes these Classes to support other Systems (Sql-Server on PC for one), please send me the changes.
All general changes will be re-published here
Copyright notice
Mark Johnson, Berlin, Germany
mj10777.de.eu
Copyright © 2003, 2004
free for private use, otherwise please make a Donation or pay Royalty to my (E-Mail) account at PayPal
E-Mail : mj10777@mj10777.de
Points of Interest
I would be very interested in hearing any reaction to this article. If an E-Mail does not
get lost in the Junk Box, I will also reply.
History
none as of yet
Alternate Link
This Articel and File's can be read and downloaded at:
http://www.mj10777.de/NETFramework/Articels/NetDbExplorer/index.htm