Click here to Skip to main content
Licence 
First Posted 17 Mar 2004
Views 96,513
Bookmarked 35 times

HyperNetDatabase

By | 21 Mar 2004 | Article
HyperNetDatabase is a single process multithreading and blackout safe database

Sample Image - maximum width is 600 pixels

Sample Image - maximum width is 600 pixels

Introduction

This project was developed in order to help users that use databases like commercial ACCESS for small projects and then are subject to commercial laws. This is a simple solution for a database engine that can supply a good power to normal database tasks. This driver is free (GPL).

Using the code

Link the two DLLs HyperNetDatabase.DLL and NetFrmExts.DLL to your project and you'll be linked. Note use R2 Only, R1 is older and unstable.

To open a database and make a select:

using HyperNetDatabase.R2;
...
Database db = new Database();
db.Open("file.hnd"); // creates or opens database
...
..
DataTable result = db.Select(
    new string[]{"SEQNAME"}, // fields as an array of strings
    "$Sequences", // Name of the table
    new object[,]{ {"SEQNAME","=",myseq} } 
  // pairs of filter conditions : ... WHERE SEQNAME=myseq AND ...
    );
..
db.Close();

 

Public Static Methods


DataRow2NameAndValue Converts a DataRow in a NameAndValue object with skipRows.

Public Instance Constructors


Database Constructor Default constructor

Public Instance Properties


Filename Filename of the database
Lock Global lock, used to lock other thread to make concurrent queries. Example: Read and then insert.
State Connection state

Public Instance Methods

AddField Adds a field
AddFieldIfNotExist Adds a field if it not exists
AddTable Adds a table
AddTableIfNotExist Adds a table if it not exists
Close Closes a database
Delete SQL DELETE query Example:
   using HyperNetDatabase.R2;
   ...
   Database db = new Database();
   db.Open("file.hnd"); 
    // creates or opens database
   ...
   string StockName = "peppers";
   DataTable result = db.Delete("Stock",
   new object[,]{ {"NAME","=",StockName} }
   );
   ...
   

Is the same as: DELETE Stock WHERE NAME=@StockName

WHERE expression: Is an C# expresion for making a where as a filter.

  • new object[,]{ {"{FIELDNAME}",{operand},{parameter}},... } Is the same as "field operand parameter AND ..."
  • null Means the same as no where condition.

Operand Effect
= Equality
> Value of left field name is greater than right constant value variable
>= Value of left field name is greater or equal than right constant value variable
< Value of left field name is less than right constant value variable
<= Value of left field name is less or equal than right constant value variable
!= Value of left field name is different than right constant value variable

DropTable Removes a table
DropTableIfExists Drops a table if the table exists
Dump Dumps pages state
ExistsTable Returns true if the table exists
FlushIndexes Destroys in memory indexes. Do this if your were walking for many tables and you memory resources are low.
ForcedInsert Overloaded. More known as Update or Insert (Sets values by a keyfield) Inserts if the condition does not match or updates if the condition matches.
   db.ForcedInsert( "Stock", "NAME", 
     "Peppers", "Qty", 0.5m );
   
Is the same as:
   SELECT Count(*) FROM STOCK WHERE NAME="Peppers";
   if count > 0 then
   UPDATE STOCK SET Qty=0.5 WHERE NAME="Peppers";
   else
   INSERT INTO STOCK (NAME,Qty) 
      VALUES ("Peppers",0.5);
   
ForcedSelect Obtains a value and if it not exists obtains it's default value
GetTableNames Gets all tables in this database
GetUserFields Fields for users
Insert Inserts data into a Table Example:
   using HyperNetDatabase.R2;
   ...
   Database db = new Database();
   db.Open("file.hnd"); 
    // creates or opens database
   ...
   string StockName = "peppers";
   DataTable result = db.Insert(
    "Stock", new object[,]
  { {"NAME",StockName}, {"QTY",0.5m} } );
   ...
   

Is the same as: INSERT INTO Stock (NAME,QTY) VALUES (@StockName,0.5);

SET expression: Is an C# expresion for indicate a FIELD with its VALUE.new object[,]{ {"{FIELDNAME}",{parameter}},... } Is the same as "SET field = parameter, ..."Example 1:

     new object[,]{ {"QTY",0.5m} }
     
Example 2:
     new object[,]{ {"STRNAME","peppers"}, 
      {"QTY",0.5m} }
     
LogToFile (inherited from LogSupport) Saves a string in the log file
Open Open
PreloadIndexes Preloads indexes for table to make reads faster
Select SQL Select query. Example:
   using HyperNetDatabase.R2;
   ...
   Database db = new Database();
   db.Open("file.hnd"); // creates or opens database
   ...
   string StockName = "peppers";
   DataTable result = db.Select(null,"Stock",
   new object[,]{ {"NAME","=",StockName} }
   );
   ...
   result = db.Select(new string[]{"NAME"},"Stock",
   new object[,]{ {"NAME","=",StockName} }
   );
   ...
   
Is the same as:
  • SELECT * FROM Stock WHERE NAME=@StockName
  • SELECT NAME FROM Stock WHERE NAME=@StockName
WHERE expression: Is an C# expresion for making a where as a filter.
  • new object[,]{ {"{FIELDNAME}", {operand},{parameter}},... } Is the same as "field operand parameter AND ..."
  • null Means the same as no where condition.

Operand Effect
= Equality
> Value of left field name is greater than right constant value variable
>= Value of left field name is greater or equal than right constant value variable
< Value of left field name is less than right constant value variable
<= Value of left field name is less or equal than right constant value variable
!= Value of left field name is different than right constant value variable

seqCreate Overloaded. Creates a sequence.
seqCurrentValue Current sequence value
seqDrop Sequence drop
seqExists Sequence exists?
seqNextValue Next sequence value (and autoincrement)
Update SQL UPDATE query Example:
   using HyperNetDatabase.R2;
   ...
   Database db = new Database();
   db.Open("file.hnd"); // creates or opens database
   ...
   string StockName = "peppers";
   DataTable result = db.Update("Stock",
   new object[,]{ {"NAME",StockName}, {"QTY",0.5m} },
   new object[,]{ {"NAME","=","pepperoni"} }
   );
   ...
   

Is the same as: UPDATE Stock SET NAME=@StockName, QTY=0.5 WHERE NAME=pepperoni

WHERE expression: Is an C# expresion for making a where as a filter.

  • new object[,]{ {"{FIELDNAME}",{operand},{parameter}},... } Is the same as "field operand parameter AND ..."
  • null Means the same as no where condition.

Operand Effect
= Equality
> Value of left field name is greater than right constant value variable
>= Value of left field name is greater or equal than right constant value variable
< Value of left field name is less than right constant value variable
<= Value of left field name is less or equal than right constant value variable
!= Value of left field name is different than right constant value variable

SET expression: Is an C# expresion for indicate a FIELD with its VALUE.

new object[,]{ {"{FIELDNAME}",{parameter}},... } is the same as "SET field = parameter, ..."

Example 1:

     new object[,]{ {"QTY",0.5m} }     
Example 2:
     new object[,]{ {"STRNAME","peppers"}, 
      {"QTY",0.5m} }     



Points of Interest

  • Support all SQL basic functions.
  • Additional features.
  • Protect from Blackouts
  • Multithreading-safe

History

RELEASE VERSION 2.0.0 NOTES - 2004-03-17

Features:

  • First stable version
  • Support all SQL basic functions.
  • Additional features.
  • Protect from Blackouts
  • Multithreading-safe

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

M L Viñas Livschitz

Web Developer

Spain Spain

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralseqCreate PinmemberRobse4:48 17 Apr '06  
GeneralGood work but too much memory used Pinmemberadamsdigiark15:44 28 Aug '04  
GeneralRe: Good work but too much memory used PinmemberM L Viñas Livschitz22:51 30 Aug '04  
GeneralStrings > 50KByte PinsussKampf-Keks14:14 15 Aug '04  
GeneralRe: Strings > 50KByte PinmemberM L Viñas Livschitz22:51 30 Aug '04  
GeneralConsult SharpHSQL Pinmemberylong6:13 18 Apr '04  
GeneralRe: Consult SharpHSQL PinmemberM L Viñas Livschitz6:22 18 Apr '04  
GeneralProtect from Blackouts PinmemberRick Crone9:04 30 Mar '04  
GeneralRe: Protect from Blackouts PinmemberM L Viñas Livschitz22:49 30 Mar '04  
GeneralRe: Protect from Blackouts PinmemberRick Crone3:13 31 Mar '04  
GeneralRe: Protect from Blackouts PinmemberM L Viñas Livschitz5:54 31 Mar '04  
GeneralNo test database in source.. PinmemberStewart.Rogers2:51 30 Mar '04  
GeneralRe: No test database in source.. PinmemberM L Viñas Livschitz3:03 30 Mar '04  
GeneralDatabase PinmemberAlex_117:36 24 Mar '04  
GeneralRe: Database PinmemberM L Viñas Livschitz6:22 25 Mar '04  
QuestionID fields? Pinmembercsmba7:36 24 Mar '04  
AnswerRe: ID fields? PinmemberM L Viñas Livschitz8:46 24 Mar '04  
GeneralRe: ID fields? Pinmembercsmba8:51 24 Mar '04  
GeneralRe: ID fields? PinmemberM L Viñas Livschitz6:20 25 Mar '04  
QuestionParser? PinmemberJeff Varszegi18:11 18 Mar '04  
AnswerRe: Parser? Pinmemberultralight323:32 19 Mar '04  
GeneralRe: Parser? PinmemberStewart.Rogers2:40 30 Mar '04  
GeneralRe: Parser? PinmemberM L Viñas Livschitz3:13 30 Mar '04  
GeneralNo source Pinmemberxanth13:35 18 Mar '04  
GeneralRe: No source Pinmemberultralight323:33 19 Mar '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 22 Mar 2004
Article Copyright 2004 by M L Viñas Livschitz
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid