Click here to Skip to main content
13,093,097 members (65,139 online)
Click here to Skip to main content
Add your own
alternative version

Stats

110K views
35 bookmarked
Posted 17 Mar 2004

HyperNetDatabase

, 21 Mar 2004
Rate this:
Please Sign up or sign in to vote.
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


DataRow2NameAndValueConverts a DataRow in a NameAndValue object with skipRows.

Public Instance Constructors


Database ConstructorDefault constructor

Public Instance Properties


FilenameFilename of the database
<IMG 
src="MlVlHyperNetDatabase/pubproperty.gif">Lock
Global lock, used to lock other thread to make concurrent queries. Example: Read and then insert.
<IMG 
src="MlVlHyperNetDatabase/pubproperty.gif">State
Connection state

Public Instance Methods

<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">AddField
Adds a field
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">AddFieldIfNotExist
Adds a field if it not exists
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">AddTable
Adds a table
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">AddTableIfNotExist
Adds a table if it not exists
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Close
Closes a database
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Delete
SQL DELETE query <example>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.

OperandEffect
=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

<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">DropTable
Removes a table
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">DropTableIfExists
Drops a table if the table exists
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Dump
Dumps pages state
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">ExistsTable
Returns true if the table exists
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">FlushIndexes
Destroys in memory indexes. Do this if your were walking for many tables and you memory resources are low.
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">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.<example>
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);
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">ForcedSelect
Obtains a value and if it not exists obtains it's default value
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">GetTableNames
Gets all tables in this database
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">GetUserFields
Fields for users
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Insert
Inserts data into a Table <example>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>Example 1:

new object[,]{ {"QTY",0.5m} }
<example>Example 2:
new object[,]{ {"STRNAME","peppers"},
 {"QTY",0.5m} }
LogToFile (inherited from LogSupport)Saves a string in the log file
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Open
Open
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">PreloadIndexes
Preloads indexes for table to make reads faster
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Select
SQL Select query. <example>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.

OperandEffect
=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

<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">seqCreate
Overloaded. Creates a sequence.
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">seqCurrentValue
Current sequence value
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">seqDrop
Sequence drop
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">seqExists
Sequence exists?
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">seqNextValue
Next sequence value (and autoincrement)
<IMG 
src="MlVlHyperNetDatabase/pubmethod.gif">Update
SQL UPDATE query <example>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.

OperandEffect
=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>Example 1:

new object[,]{ {"QTY",0.5m} }
<example>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

Share

About the Author

M L Viñas Livschitz
Web Developer
Spain Spain
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralseqCreate Pin
Robse17-Apr-06 4:48
memberRobse17-Apr-06 4:48 
GeneralGood work but too much memory used Pin
adamsdigiark28-Aug-04 15:44
memberadamsdigiark28-Aug-04 15:44 
GeneralRe: Good work but too much memory used Pin
M L Viñas Livschitz30-Aug-04 22:51
memberM L Viñas Livschitz30-Aug-04 22:51 
GeneralStrings &gt; 50KByte Pin
Kampf-Keks15-Aug-04 14:14
sussKampf-Keks15-Aug-04 14:14 
GeneralRe: Strings &gt; 50KByte Pin
M L Viñas Livschitz30-Aug-04 22:51
memberM L Viñas Livschitz30-Aug-04 22:51 
GeneralConsult SharpHSQL Pin
ylong18-Apr-04 6:13
memberylong18-Apr-04 6:13 
GeneralRe: Consult SharpHSQL Pin
M L Viñas Livschitz18-Apr-04 6:22
memberM L Viñas Livschitz18-Apr-04 6:22 
GeneralProtect from Blackouts Pin
Rick Crone30-Mar-04 9:04
memberRick Crone30-Mar-04 9:04 
GeneralRe: Protect from Blackouts Pin
M L Viñas Livschitz30-Mar-04 22:49
memberM L Viñas Livschitz30-Mar-04 22:49 
GeneralRe: Protect from Blackouts Pin
Rick Crone31-Mar-04 3:13
memberRick Crone31-Mar-04 3:13 
GeneralRe: Protect from Blackouts Pin
M L Viñas Livschitz31-Mar-04 5:54
memberM L Viñas Livschitz31-Mar-04 5:54 
GeneralNo test database in source.. Pin
Stewart.Rogers30-Mar-04 2:51
memberStewart.Rogers30-Mar-04 2:51 
GeneralRe: No test database in source.. Pin
M L Viñas Livschitz30-Mar-04 3:03
memberM L Viñas Livschitz30-Mar-04 3:03 
GeneralDatabase Pin
Alex_124-Mar-04 17:36
memberAlex_124-Mar-04 17:36 
GeneralRe: Database Pin
M L Viñas Livschitz25-Mar-04 6:22
memberM L Viñas Livschitz25-Mar-04 6:22 
QuestionID fields? Pin
csmba24-Mar-04 7:36
membercsmba24-Mar-04 7:36 
AnswerRe: ID fields? Pin
M L Viñas Livschitz24-Mar-04 8:46
memberM L Viñas Livschitz24-Mar-04 8:46 
GeneralRe: ID fields? Pin
csmba24-Mar-04 8:51
membercsmba24-Mar-04 8:51 
GeneralRe: ID fields? Pin
M L Viñas Livschitz25-Mar-04 6:20
memberM L Viñas Livschitz25-Mar-04 6:20 
QuestionParser? Pin
Jeff Varszegi18-Mar-04 18:11
memberJeff Varszegi18-Mar-04 18:11 
AnswerRe: Parser? Pin
ultralight3219-Mar-04 3:32
memberultralight3219-Mar-04 3:32 
GeneralRe: Parser? Pin
Stewart.Rogers30-Mar-04 2:40
memberStewart.Rogers30-Mar-04 2:40 
GeneralRe: Parser? Pin
M L Viñas Livschitz30-Mar-04 3:13
memberM L Viñas Livschitz30-Mar-04 3:13 
GeneralNo source Pin
xanth18-Mar-04 13:35
memberxanth18-Mar-04 13:35 
GeneralRe: No source Pin
ultralight3219-Mar-04 3:33
memberultralight3219-Mar-04 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 22 Mar 2004
Article Copyright 2004 by M L Viñas Livschitz
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid