<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>C# example using WD 16 .NET assembly</title>
        <description> I have stopped my attempt to use C# for finger scanners for now but I can give anyone interested my test project and C# solution if it is of interest. Just send me an email or post your email here and I will get the code to you.

I encourage all that use .NET to add to this sample or add their own suggestions.

Jeff Graham
Cascade Consulting

Related threads:
[forum.mysnip.de]
[forum.mysnip.de]
[forum.mysnip.de]
[forum.mysnip.de]
[forum.mysnip.de]

Code for WD .NET assembly class

// .NET assebly for accessing HF Fingerprints and Accounts from C#

//--- LOG ----------------------------------------------------------------------------------------------------------------------------------
//2011-09-06	JWG		clHFAccess		- New class
//2011-11-08    JWG     Note that properties do not seem to show in C# even if marked PUBLIC =&amp;gt; must have Get.. and Set.. methods
//--- END LOG ------------------------------------------------------------------------------------------------------------------------------

clHFAccess is class 
	PRIVATE
		m_cnxHFConn is Connection
		m_bufFingerprints is Buffer
		m_sTestString is string = &amp;quot;Default value!&amp;quot;	
		gm_sDataPath is string = &amp;quot;&amp;lt;none&amp;gt;&amp;quot;
	PUBLIC
		gm_bIsConnected is boolean = False
		gm_iNbrRecords is int = 0
	END


PROCEDURE PUBLIC p_sDataPath()
RESULT gm_sDataPath

PROCEDURE PUBLIC p_sDataPath(sValue is string)
HCloseConnection(m_cnxHFConn)
gm_bIsConnected = False
IF fDirectoryExist(sValue) THEN 
	m_cnxHFConn..Source = sValue
	IF HOpenConnection(m_cnxHFConn) THEN 
		IF HChangeConnection(Fingerprints,m_cnxHFConn) THEN // Only file used by this .NET dll
			gm_bIsConnected = True
			gm_iNbrRecords = HNbRec(Fingerprints)    
			gm_bIsConnected = False
			gm_sDataPath = sValue
		END
	END
END
PROCEDURE PUBLIC p_sTestString()
RESULT m_sTestString

PROCEDURE PUBLIC p_sTestString(par_Value is string)
m_sTestString = par_Value

PROCEDURE Constructor()
// Set public property to indicate HF is connected
//gm_sDataPath = fDataDir()  // This does not work as fDataDir unique to WinDev
gm_sDataPath = fCurrentDir()
m_cnxHFConn..Provider=hAccessHF7
m_cnxHFConn..Password = &amp;quot;&amp;quot;
m_cnxHFConn..Source=fDataDir()  //+&amp;quot;\Fingerprints.fic&amp;quot; 
IF HOpenConnection(m_cnxHFConn) THEN 
	IF HChangeConnection(Fingerprints,m_cnxHFConn) THEN // Only file used by this .NET dll
		gm_bIsConnected = True
		gm_iNbrRecords = HNbRec(Fingerprints)    
		gm_bIsConnected = False
	END
END
RESULT gm_bIsConnected
PROCEDURE Destructor()
// NOTE - This code causes AccessViolationException
//if gm_bIsConnected then
//	HCloseConnection(m_cnxHFConn)
//END

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] GetNextFingerprint (&amp;lt;ID&amp;gt; is int, &amp;lt;iAccountsID&amp;gt; is int, &amp;lt;iDistrictStudentNbr&amp;gt; is int, &amp;lt;aFeatures&amp;gt;)
//
// Parameters:
//	ID (int): Fingerprints ID
//	iAccountsID (int): AccMeals account identifier
//	iDistrictStudentNbr (int): Unique identifier of student
//	aFeatures: Template data
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
//PROCEDURE GetNextFingerprint(LOCAL ID is int, LOCAL iAccountsID is int, LOCAL iDistrictStudentNbr is int, LOCAL aFeatures is array of byte ) 
PROCEDURE GetNextFingerprint(ID is int, iAccountsID is int, iDistrictStudentNbr is int, aFeatures) // is array of byte )
bResult is boolean = HReadNext(Fingerprints,ID,hLockNo)
IF bResult THEN
	ID = Fingerprints.ID
	iAccountsID = Fingerprints.AccountsID
	iDistrictStudentNbr = Fingerprints.DistrictStudentNbr
	IF Fingerprints.Features..Null = False THEN  
		 //		aFeatures = Fingerprints.Features
		Deserialize(aFeatures,Fingerprints.Features,psdBinary)
	END
END
RESULT bResult
//result gm_bIsConnected

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] GetTestString ()
//
// Parameters:
//	None
// Return Value:
// 	string: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE GetTestString()
RESULT m_sTestString

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//SetTestString (&amp;lt;sValue&amp;gt; is string)
//
// Parameters:
//	sValue (string): &amp;lt;specify the role of value&amp;gt;
// Return Value:
// 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE SetTestString(LOCAL sValue is string)
m_sTestString = sValue


//PROCEDURE GetFirstFingerprint(local ID is int, LOCAL iAccountsID is int, LOCAL iDistrictStudentNbr is int, LOCAL aFeatures is array of byte )
PROCEDURE GetFirstFingerprint(ID is int, iAccountsID is int, iDistrictStudentNbr is int, aFeatures) // is array of byte )
bResult is boolean = HReadFirst(Fingerprints)
IF bResult THEN
	ID = Fingerprints.ID
	iAccountsID = Fingerprints.AccountsID
	iDistrictStudentNbr = Fingerprints.DistrictStudentNbr
	IF Fingerprints.Features..Null = False THEN 
//		aFeatures = Fingerprints.Features
		Deserialize(aFeatures,Fingerprints.Features,psdBinary)
	END
END
RESULT bResult
// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] WriteData (&amp;lt;iAccountsID&amp;gt; is int, &amp;lt;iDistrictStudentNbr&amp;gt; is int, &amp;lt;sFingerID&amp;gt; is string, &amp;lt;aTemplate&amp;gt; is array)
//
// Parameters:
//	iAccountsID (int): &amp;lt;specify the role of siAccountsID&amp;gt;
//	iDistrictStudentNbr (int): &amp;lt;specify the role of siDistrictStudentNbr&amp;gt;
//	sFingerID (string): &amp;lt;specify the role of sFingerID&amp;gt;
//	aTemplate (array): &amp;lt;specify the role of bufFeatures&amp;gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
//PROCEDURE WriteData(iAccountsID is int, iDistrictStudentNbr is int, sFingerID is string, aFeatures is array of byte  )  // This causes &amp;quot;ref &amp;lt;parm&amp;gt;&amp;quot; calls

PROCEDURE WriteData(LOCAL iAccountsID is int, LOCAL iDistrictStudentNbr is int, LOCAL sFingerID is string, LOCAL aTemplate is array of 1-byte unsigned int )

bSuccess is boolean = False
HReset(Fingerprints)
Fingerprints.AccountsID = iAccountsID
Fingerprints.DistrictStudentNbr = iDistrictStudentNbr
Fingerprints.FingerID = sFingerID
//Serialize(aFeatures,Fingerprints.Features,psdBinary)
//Fingerprints.Features = aTemplate  // just puts address in binary field
bufTemplate is Buffer
Serialize(aTemplate,bufTemplate,psdBinary)
Fingerprints.Features = bufTemplate

IF HAdd(Fingerprints) THEN
	bSuccess = True
END
gm_iNbrRecords = HNbRec(Fingerprints)    // Update class info
RESULT bSuccess
// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] TestA (&amp;lt;p1&amp;gt; is int, &amp;lt;p2&amp;gt; is array)
//
// Parameters:
//	p1 (int): &amp;lt;specify the role of p1&amp;gt;
//	p2 (array): &amp;lt;specify the role of p2&amp;gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE TestA(p1 is int,p2 is array of byte)
temp is array of byte = [1,2,3]
p1 += 1
p2 = temp
RESULT True
// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] TestB (&amp;lt;p1&amp;gt; is int, &amp;lt;p2&amp;gt;)
//
// Parameters:
//	p1 (int): &amp;lt;specify the role of p1&amp;gt;
//	p2: &amp;lt;specify the role of p2&amp;gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE TestB(p1 is int, p2)
temp is array of byte = [2,3,4,5]
p1 += 1
p2 = temp
RESULT True


// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] TestC (&amp;lt;p1&amp;gt; is int [, &amp;lt;p2&amp;gt; is array])
//
// Parameters:
//	p1 (int): &amp;lt;specify the role of p1&amp;gt;
//	p2 (array - default value=0): &amp;lt;specify the role of p2&amp;gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE TestC(p1 is int,p2 is array of 1-byte unsigned int = Null)
temp is array of byte = [10,11,12]
p1 += 1
IF MyParameters..NbReceived = 2 THEN
	p2 = temp
	RESULT True
ELSE
	RESULT False
END

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] TestD (&amp;lt;p1&amp;gt; is int, &amp;lt;p2&amp;gt; is COMObject)
//
// Parameters:
//	p1 (int): &amp;lt;specify the role of p1&amp;gt;
//	p2 (COMObject): &amp;lt;specify the role of p2&amp;gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
//	p1 (int): &amp;lt;specify the role of p1&amp;gt;
//	p2 (array - default value=0): &amp;lt;specify the role of p2&amp;gt;
PROCEDURE TestD(p1 is int, p2 is COMObject)
temp is array of byte = [13,14,15]
p1 += 1
IF MyParameters..NbReceived = 2 THEN
	p2 = temp
	RESULT True
ELSE
	RESULT False
END

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] GetDataPath ()
//
// Parameters:
//	None
// Return Value:
// 	string: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE GetDataPath()
RESULT p_sDataPath

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//SetDataPath (&amp;lt;sValue&amp;gt; is string)
//
// Parameters:
//	sValue (string): &amp;lt;specify the role of sValue&amp;gt;
// Return Value:
// 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE SetDataPath(LOCAL sValue is string)
p_sDataPath = sValue

// Summary: &amp;lt;specify the procedure action&amp;gt;
// Syntax:
//[ &amp;lt;Result&amp;gt; = ] CloseDB ()
//
// Parameters:
//	None
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE CloseDB()
IF HCloseConnection(m_cnxHFConn) THEN
	gm_bIsConnected = False
END
RESULT gm_bIsConnected

C# code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Neurotec.Biometrics;
using Neurotec.Licensing;
using WL;


namespace Test_CS
{
    public partial class FormTest : Form
    {
        public FormTest()
        {
            InitializeComponent();
        }
        private string pathTestData = @&amp;quot;D:\BioMetrics\Test_Data&amp;quot;;

        private void buttonOLE_Click(object sender, EventArgs e)
        {
            /*
            Connection to a HyperFileSQL Classic database without specifying the analysis:
                Provider=PCSOFT.HFSQL;Initial Catalog=c:\My HyperFileSQL Database
            Connection to a HyperFileSQL Classic database byspecifying the analysis:
                Provider=PCSOFT.HFSQL;Data Source=c:\My HyperFileSQL Database\MyAnalysis.wdd;Initial Catalog=c:\My HyperFileSQL Database
            Connection to a HyperFileSQL Client/Server database:
                Provider=PCSOFT.HFSQL;Data Source=serverdb.mycompany.fr:4910;User ID=admin;Password=secret;Initial Catalog=MyDatabase
            Connection to a HyperFileSQL Client/Server database with password-protected files that use the Russian character set:
                Provider=PCSOFT.HFSQL;Data Source=serverdb.mycompany.fr;User ID=user;Initial Catalog=MyRussianDatabase;Extended Properties=&amp;quot;Password=*:secret1;Password=File2:secret2;Language=KOI8-R&amp;quot;
            Note: In this example, all the database files are protected by the &amp;quot;secret1&amp;quot; password except for the &amp;quot;File2&amp;quot; file that is protected by the &amp;quot;secret2&amp;quot; password.
            */

            textOLE.Text = &amp;quot;&amp;quot;;
            try
            {
                System.Data.OleDb.OleDbConnection myOleDb = new System.Data.OleDb.OleDbConnection
                    (@&amp;quot;Provider=PCSOFT.HFSQL;Data Source=D:\BioMetrics\\VF_CS_Test\\VF_CS_Test.wdd;Initial Catalog=&amp;quot;+pathTestData+&amp;quot;;&amp;quot;); //D:\\BioMetrics\\WD_Net\\Exe;&amp;quot;);
                    //(&amp;quot;Provider=PCSOFT.HFSQL;Data Source=D:\\BioMetrics\\VF_CS_Test\\VF_CS_Test.wdd;Initial Catalog=D:\\BioMetrics\\VF_CS_Test\\exe:&amp;quot;);
                    // (Provider=PCSOFT.HFSQL;Data Source=c:\My HyperFileSQL Database\MyAnalysis.wdd;Initial Catalog=c:\My HyperFileSQL Database); 
                    //(&amp;quot;Provider=PCSOFT.HFSQL;Data Source=c:\\My HyperFileSQL Database\\MyAnalysis.wdd;Initial Catalog=c:\\My HyperFileSQL Database&amp;quot;);
                myOleDb.Open();
                // Specify the Query
                OleDbCommand MyQuery = new OleDbCommand(&amp;quot;SELECT ID,AccountsID,DistrictStudentNbr,FingerID,Features FROM FingerPrints&amp;quot;,myOleDb);
                // Run the Query
                //OleDbDataReader MyData = MyQuery.ExecuteReader();
                // Read first
                OleDbDataReader MyDataReader = MyQuery.ExecuteReader();
                //MyDataReader.Read();
                // Display
                //textOLE.AppendText(MyDataReader.ToString());
                for (int i = 1; i &amp;lt; 15; i++)
                {
                    if (MyDataReader.Read())
                    {
                        var ID = MyDataReader.GetValue(0);
                        var accountID = MyDataReader.GetValue(1);
                        var districtStudentNbr = MyDataReader.GetValue(2);
                        var fingerID = MyDataReader.GetValue(3);
                        var features = MyDataReader.GetValue(4);
                        // Display
                        textOLE.AppendText(string.Format(&amp;quot;ID={0},AccountID={1},FingerID={2},FeaturesType={3}\n &amp;quot;,ID.ToString(),accountID.ToString(),fingerID,features.GetType()));
                    }
                    else
                    {
                        textOLE.AppendText(&amp;quot;EOF&amp;quot;);
                        break;
                    }
                }
                // Close
                MyDataReader.Close();
                myOleDb.Close();
        
            }
            catch(Exception ex)
            {
                textOLE.AppendText(&amp;quot;Error in connect: \n&amp;quot; + ex.Message);
            }
        }
 
        private void buttonMDB_Click(object sender, EventArgs e)
        {
            textMDB.Text = &amp;quot;&amp;quot;;
            try
            {
                System.Data.OleDb.OleDbConnection myMDB = new System.Data.OleDb.OleDbConnection
                    (&amp;quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&amp;quot;+pathTestData+@&amp;quot;\FPID.mdb;&amp;quot;); //  D:\\BioMetrics\\VF_CS_Test\\Exe\\FPID.mdb;&amp;quot;);
                myMDB.Open();
                // Specify the Query
                OleDbCommand MyQuery = new OleDbCommand(&amp;quot;SELECT AccountsID FROM FingerPrints&amp;quot;,myMDB);
                OleDbCommand myCommand = myMDB.CreateCommand();
                myCommand.CommandText = &amp;quot;FingerPrints&amp;quot;;
                // Run the Query
                OleDbDataReader MyDataReader = MyQuery.ExecuteReader();

                for (int i = 1; i &amp;lt; 15; i++)
                {
                    MyDataReader.Read();
                    var accountID = MyDataReader.GetValue(0);
                    // Display
                    textMDB.AppendText(accountID.ToString() + &amp;quot;; &amp;quot;);
                }
                // Close
                MyDataReader.Close();
                myMDB.Close();

            }
            catch (Exception ex)
            {
                textMDB.AppendText(&amp;quot;Error in MDB: \n&amp;quot; + ex.Message);
            }

        }

        private void buttonConvert_Click(object sender, EventArgs e)
        {

            textConvert.Text = &amp;quot;Start of test.\n&amp;quot;;
            try
            {
                WL.clHFAccess hfAccess = new clHFAccess();
                hfAccess.SetDataPath(@&amp;quot;D:\Biometrics\Test_Data&amp;quot;); 
                int _AccountsID = 0;
                int _DistrictStudentNbr = 0;
                string _FingerID;
                //byte[] _FingerPrint;
                byte[] vf42_template;
                byte[] vf63_template;
                // Data access by using a DataSet
                FPIDTestDataSetTableAdapters.Fingerprints1TableAdapter taFP1 = new FPIDTestDataSetTableAdapters.Fingerprints1TableAdapter();
                taFP1.Connection.ConnectionString = @&amp;quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\BioMetrics\Test_Data\FPID.mdb&amp;quot;;
                FPIDTestDataSet dsFP1s = new FPIDTestDataSet(); 
                taFP1.Fill(dsFP1s.Fingerprints1);  
                textConvert.AppendText(string.Format(&amp;quot;WD Fingerprints: {2} Data path = {0}\nAccess MDB path = {1}\n&amp;quot;,hfAccess.GetDataPath(),taFP1.Connection.DataSource,hfAccess.gm_iNbrRecords)); 
                int iCount = 0;
                foreach (FPIDTestDataSet.Fingerprints1Row fingerprint in dsFP1s.Fingerprints1.Rows)
                {
                    iCount++;
                    //if (iCount &amp;gt; 15) break;
                    // Convert old template to new format:
                    vf42_template = fingerprint.Features;
                    NFRecord nfrecord = new NFRecord(vf42_template);
                    vf63_template = nfrecord.Save();
                    // Write to HF
                    _AccountsID = fingerprint.AccountsID;
                    _DistrictStudentNbr = fingerprint.DistrictStudentNbr;
                    _FingerID = fingerprint.FingerID;
                    if (hfAccess.WriteData(_AccountsID, _DistrictStudentNbr, _FingerID,  vf63_template) )
                    {
                        // Message
                        textConvert.AppendText(fingerprint.AccountsID.ToString() + &amp;quot;; &amp;quot;);
                    }
                    else
                    {
                        textConvert.AppendText(&amp;quot;Error: &amp;quot;+fingerprint.AccountsID.ToString() + &amp;quot;; &amp;quot;);
                    }
                    nfrecord.Dispose();
                }
                textConvert.AppendText(string.Format(&amp;quot;\nAdded {0} HF fingerprints.\n Now {1} fingerprints.&amp;quot;,iCount,hfAccess.gm_iNbrRecords));
                hfAccess = null;
                dsFP1s.Dispose();
                taFP1.Dispose();
            }
            catch (Exception ex)
            {
                // Display the errors
                textConvert.AppendText(&amp;quot;Error: Source = &amp;quot; + ex.Source + &amp;quot;\n&amp;quot;);
                textConvert.AppendText(&amp;quot;Error: Message = &amp;quot; + ex.Message + &amp;quot;\n&amp;quot;);
            }
            
            textConvert.AppendText(&amp;quot; End of test.&amp;quot;);
        }

        private void buttonDataSet_Click(object sender, EventArgs e) // Read Access with dataset
        {
            textDataSet.Text = &amp;quot;&amp;quot;;
            try
            {
                // Data access by using a DataSet
                //FPIDDataSetTableAdapters.FingerprintsTableAdapter ctaFPID = new FPIDDataSetTableAdapters.FingerprintsTableAdapter;
                //FPIDDataSet
                FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter taFP = new FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter();
                FPIDDataSet_MDB dsFPs = new FPIDDataSet_MDB();
                taFP.Fill(dsFPs.Fingerprints);
                int iCount = 0;
                foreach (FPIDDataSet_MDB.FingerprintsRow fingerprint in dsFPs.Fingerprints.Rows)
                {
                    iCount++;
                    if (iCount &amp;gt; 15) break;
                    textDataSet.AppendText(fingerprint.AccountsID.ToString() + &amp;quot;; &amp;quot;);
                }
            }
            catch (OdbcException eExcpt)
            {
                // Display the errors
                textDataSet.AppendText(&amp;quot;Error: Source = &amp;quot; + eExcpt.Source);
                textDataSet.AppendText(&amp;quot;Error: Message = &amp;quot; + eExcpt.Message);
                //Console.WriteLine(&amp;quot;Source = &amp;quot; + eExcpt.Source);
                //Console.WriteLine(&amp;quot;Message = &amp;quot; + eExcpt.Message);
            }
        }

        #region Comments and code showing limitations of PC Soft data access 
  /* Note the code below gets the following exception: 
  * The ICommandWithParameters interface is not supported by the &amp;#039;PCSOFT.HFSQL&amp;#039; provider.  
  * Command parameters are unsupported with the current provider.
  *           try
            {
                // FPID Data access by using a DataSet
                FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter taFP = new FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter();
                FPIDDataSet_MDB dsFPs = new FPIDDataSet_MDB();
                taFP.Fill(dsFPs.Fingerprints);

                // .FIC access by =======================================================
                System.Data.OleDb.OleDbConnection myFIC = new System.Data.OleDb.OleDbConnection
                    (&amp;quot;Provider=PCSOFT.HFSQL;Data Source=D:\\BioMetrics\\VF_CS_Test\\VF_CS_Test.wdd;Initial Catalog=D:\\BioMetrics\\VF_CS_Test\\exe;&amp;quot;);
                // Experiment with making a data adapter for Insert &amp;amp; Modify
                OleDbDataAdapter adapter = CreateDataAdapter(&amp;quot;SELECT * FROM Fingerprints&amp;quot;, myFIC);

                DataSet dsFIC = new DataSet();
                adapter.Fill(dsFIC);

                // Process FPID records
                int iCount = 0;
                foreach (FPIDDataSet_MDB.FingerprintsRow fingerprint in dsFPs.Fingerprints.Rows)
                {
                    iCount++;
                    if (iCount &amp;gt; 15) break;
                    textConvert.AppendText(fingerprint.AccountsID.ToString() + &amp;quot;; &amp;quot;);
                    // Add to FIC Fingerprints
                   // Parameters not supported by PCSoft
                    //DataRow newFIC = dsFIC.Tables[0].NewRow();
                    //newFIC[&amp;quot;AccountsID&amp;quot;] = fingerprint.AccountsID;
                    //newFIC[&amp;quot;FingerID&amp;quot;] = fingerprint.FingerID;
                    //newFIC[&amp;quot;DistrictStudentNbr&amp;quot;] = fingerprint.DistrictStudentNbr;
                    //byte[] vf42_template = fingerprint.Features;
                    ////NFRecord nfrecord = new NFRecord(vf42_template);
                    ////newFIC[&amp;quot;Features&amp;quot;] = nfrecord;
                    //newFIC[&amp;quot;Features&amp;quot;] = vf42_template;
                    //dsFIC.Tables[0].Rows.Add(newFIC);
                  
                    // Try commands:
                    myFIC.Open();
                    OleDbCommand addFIC = new OleDbCommand(
                        &amp;quot;INSERT INTO Fingerprints (AccountsID) &amp;quot; +
                        &amp;quot;VALUES (?)&amp;quot;, myFIC);
                    //&amp;quot;INSERT INTO Fingerprints (Features, FingerID, AccountsID, DistrictStudentNbr) &amp;quot; +
                    //&amp;quot;VALUES (?, ?, ?, ?)&amp;quot;, myFIC);
                    OleDbParameter p1 = new OleDbParameter();
                    addFIC.Parameters.Add(p1);
                    p1.Value = fingerprint.AccountsID;
                    //fingerprint.Features, fingerprint.FingerID, fingerprint.AccountsID, fingerprint.DistrictStudentNbr);
                    //addFIC.CommandType = System.Data.CommandType.TableDirect;
                    int iAdded = addFIC.ExecuteNonQuery();
                    MessageBox.Show(&amp;quot;Added {0} rows.&amp;quot;, iAdded.ToString());
                }
                adapter.Update(dsFIC);
            }
            catch (OdbcException eExcpt)
            {
                // Display the errors
                textConvert.AppendText(&amp;quot;Error: Source = &amp;quot; + eExcpt.Source);
                textConvert.AppendText(&amp;quot;Error: Message = &amp;quot; + eExcpt.Message);
                //Console.WriteLine(&amp;quot;Source = &amp;quot; + eExcpt.Source);
                //Console.WriteLine(&amp;quot;Message = &amp;quot; + eExcpt.Message);
            }
        }


        public static OleDbDataAdapter CreateDataAdapter(string selectCommand,
        OleDbConnection connection)
        {
        }

           OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand, connection);

            adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

            // Create the Insert, Update and Delete commands.
            adapter.InsertCommand = new OleDbCommand(
                &amp;quot;INSERT INTO Fingerprints (Features, FingerID, AccountsID, DistrictStudentNbr) &amp;quot; +
                &amp;quot;VALUES (?, ?, ?, ?)&amp;quot;, connection);

            adapter.UpdateCommand = new OleDbCommand(
                &amp;quot;UPDATE Fingerprints SET Features = ?, FingerID, AccountsID = ?, DistrictStudentNbr = ? &amp;quot; +
                &amp;quot;WHERE AccountsID = ?&amp;quot;, connection);

            adapter.DeleteCommand = new OleDbCommand(
                &amp;quot;DELETE FROM Fingerprints WHERE AccountsID = ?&amp;quot;, connection);

            // Create the parameters. Add others !@!!!!!!!!!!!!!!!!!
            adapter.InsertCommand.Parameters.Add(&amp;quot;@AccountsID&amp;quot;,
                OleDbType.Integer, 10, &amp;quot;AccountsID&amp;quot;);
            adapter.InsertCommand.Parameters.Add(&amp;quot;@DistrictStudentNbr&amp;quot;,
                OleDbType.Integer, 10, &amp;quot;DistrictStudentNbr&amp;quot;);
            adapter.InsertCommand.Parameters.Add(&amp;quot;@FingerID&amp;quot;,
                OleDbType.VarChar, 50, &amp;quot;FingerID&amp;quot;);
            adapter.InsertCommand.Parameters.Add(&amp;quot;@Features&amp;quot;,
                OleDbType.Binary, 0, &amp;quot;Features&amp;quot;);

            adapter.UpdateCommand.Parameters.Add(&amp;quot;@AccountsID&amp;quot;,
                OleDbType.Integer, 10, &amp;quot;AccountsID&amp;quot;);
            adapter.UpdateCommand.Parameters.Add(&amp;quot;@DistrictStudentNbr&amp;quot;,
                OleDbType.Integer, 10, &amp;quot;DistrictStudentNbr&amp;quot;);
            adapter.UpdateCommand.Parameters.Add(&amp;quot;@FingerID&amp;quot;,
                OleDbType.VarChar, 50, &amp;quot;FingerID&amp;quot;);
            adapter.UpdateCommand.Parameters.Add(&amp;quot;@Features&amp;quot;,
                OleDbType.Binary, 0, &amp;quot;Features&amp;quot;);

            adapter.DeleteCommand.Parameters.Add(&amp;quot;@AccountsID&amp;quot;,
                OleDbType.Char, 5, &amp;quot;AccountsID&amp;quot;).SourceVersion =
                DataRowVersion.Original;
            return (adapter);
        }
*/
#endregion

        private void buttonWL_Click(object sender, EventArgs e)
        {
            //var testWL = &amp;quot;Test&amp;quot;;
            //var param1 = &amp;quot;Param1&amp;quot;;
            //clLog testLog = new clLog(ref testWL, ref param1);  

            WL.clHFAccess hfAccess = new clHFAccess();
            textWL.Text = &amp;quot;Starting clHFAccess test.\n&amp;quot;;
            textWL.AppendText(&amp;quot;Data Path = &amp;quot;+hfAccess.GetDataPath()+&amp;quot;\n&amp;quot;);
            textWL.AppendText(&amp;quot;hfAccess.TestString = &amp;quot; + hfAccess.GetTestString()+&amp;quot;\n&amp;quot;);
            // Read records:
            textWL.AppendText( &amp;quot;\nStarting Records test usingg clAcess.\n&amp;quot;); 
            textWL.AppendText(&amp;quot;hfAccess.TestString = &amp;quot; + hfAccess.GetTestString() + &amp;quot;\n&amp;quot;);
            int nbrRecords = hfAccess.gm_iNbrRecords;
            textWL.AppendText(&amp;quot;Number of Records = &amp;quot; + nbrRecords.ToString() + &amp;quot;\n&amp;quot;);
            int _ID = 0;
            int _AccountsID = 0;
            int _DistrictStudentNbr = 0;
            //var _FingerPrint = new Neurotec.IO.NBuffer(byte[]);// _Buffer);
            //NFRecord _FingerPrint = new NFRecord(); // _Buffer);
            //Neurotec.IO.NBuffer _FingerPrint;
            //byte[] _FingerPrint;
            //object _FingerPrint = new byte[100];
            //Buffer _FingerPrint;
            //byte[] _FingerPrint = new byte[100];
            //Byte[] _FingerPrint = new Byte[100];
            //try
            //{
            //    if (hfAccess.GetFirstFingerprint(ref _ID, ref _AccountsID, ref _DistrictStudentNbr,ref _FingerPrint))
            //    //if (hfAccess.GetFirstFingerprint( _ID,  _AccountsID,  _DistrictStudentNbr,  _FingerPrint)) 

            //    {
            //        do
            //        {
            //            //textWLAppendText(&amp;quot;Processing Account: &amp;quot; + _AccountsID.ToString()+
            //            //   &amp;quot;, FP_Length = &amp;quot;+_FingerPrint.Length.ToString()+ &amp;quot;\n&amp;quot;);
            //            textWL.AppendText(string.Format(&amp;quot;Processing ID={0} Account: {1}, FP_Length = {2}\n&amp;quot;, _ID, _AccountsID.ToString(),
            //              _FingerPrint.Length));
            //        }
            //        while (hfAccess.GetNextFingerprint(ref _ID, ref _AccountsID, ref _DistrictStudentNbr, ref _FingerPrint));
            //        //while (hfAccess.GetNextFingerprint( _ID, _AccountsID, _DistrictStudentNbr,  _FingerPrint));
            //    }
            //}
            //catch (Exception  ex)
            //{
            //    textWL.AppendText(&amp;quot;Exception: &amp;quot; + ex.Message + &amp;quot;\n&amp;quot;);
            //}
            //hfAccess = null;  // How to dispose? (Getting call stack error)

        }

        private void FormTest_Load(object sender, EventArgs e)
        {
 
        }

        private void buttonWL2_Click(object sender, EventArgs e)
        {
            // Test different methods of passing data from WinDev to C#
            clHFAccess wlTest = new clHFAccess();
            textWL.Text = &amp;quot;Start of parameter test.\n&amp;quot;;
            int testInt = 0;
            byte[] testArray = new byte[20];

            //wlTest.TestD(ref testInt,ref testArray);
            //textWL.AppendText(string.Format(&amp;quot;Test D: testInt={0}, testArray upper bound={1}\n&amp;quot;, testInt, testArray.GetLength(0)));

            wlTest.TestC(ref testInt, ref testArray);
            textWL.AppendText(string.Format(&amp;quot;Test C: testInt={0}, testArray upper bound={1}\n&amp;quot;, testInt, testArray.GetLength(0)));

            textWL.AppendText(&amp;quot;End of test.\n&amp;quot;);
            wlTest = null;
        }

    }
}
</description>
        <link>https://www.wxforum.info/read.php?27161,118845,118845#msg-118845</link>
        <lastBuildDate>Tue, 19 May 2026 03:24:14 +0200</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://www.wxforum.info/read.php?27161,118845,798001#msg-798001</guid>
            <title>Re: C# example using WD 16 .NET assembly</title>
            <link>https://www.wxforum.info/read.php?27161,118845,798001#msg-798001</link>
            <description><![CDATA[ I would like for source code of your C# project and a bit help on my project for connecting HFSQL DB with asp .net web api]]></description>
            <dc:creator>DJ</dc:creator>
            <category>WinDev Solutions</category>
            <pubDate>Thu, 16 May 2024 15:07:32 +0200</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27161,118845,118845#msg-118845</guid>
            <title>C# example using WD 16 .NET assembly</title>
            <link>https://www.wxforum.info/read.php?27161,118845,118845#msg-118845</link>
            <description><![CDATA[ I have stopped my attempt to use C# for finger scanners for now but I can give anyone interested my test project and C# solution if it is of interest. Just send me an email or post your email here and I will get the code to you.<br />
<br />
I encourage all that use .NET to add to this sample or add their own suggestions.<br />
<br />
Jeff Graham<br />
Cascade Consulting<br />
<br />
Related threads:<br />
[<a href="http://forum.mysnip.de/read.php?27131,118451,118451#msg-118451"  rel="nofollow">forum.mysnip.de</a>]<br />
[<a href="http://forum.mysnip.de/read.php?27131,115437,115445#msg-115445"  rel="nofollow">forum.mysnip.de</a>]<br />
[<a href="http://forum.mysnip.de/read.php?27131,114797,115335#msg-115335"  rel="nofollow">forum.mysnip.de</a>]<br />
[<a href="http://forum.mysnip.de/read.php?27131,118464,118464#msg-118464"  rel="nofollow">forum.mysnip.de</a>]<br />
[<a href="http://forum.mysnip.de/read.php?28849,118453"  rel="nofollow">forum.mysnip.de</a>]<br />
<br />
<b>Code for WD .NET assembly class</b><br />
<pre class="bbcode">
// .NET assebly for accessing HF Fingerprints and Accounts from C#

//--- LOG ----------------------------------------------------------------------------------------------------------------------------------
//2011-09-06	JWG		clHFAccess		- New class
//2011-11-08    JWG     Note that properties do not seem to show in C# even if marked PUBLIC =&gt; must have Get.. and Set.. methods
//--- END LOG ------------------------------------------------------------------------------------------------------------------------------

clHFAccess is class 
	PRIVATE
		m_cnxHFConn is Connection
		m_bufFingerprints is Buffer
		m_sTestString is string = &quot;Default value!&quot;	
		gm_sDataPath is string = &quot;&lt;none&gt;&quot;
	PUBLIC
		gm_bIsConnected is boolean = False
		gm_iNbrRecords is int = 0
	END


PROCEDURE PUBLIC p_sDataPath()
RESULT gm_sDataPath

PROCEDURE PUBLIC p_sDataPath(sValue is string)
HCloseConnection(m_cnxHFConn)
gm_bIsConnected = False
IF fDirectoryExist(sValue) THEN 
	m_cnxHFConn..Source = sValue
	IF HOpenConnection(m_cnxHFConn) THEN 
		IF HChangeConnection(Fingerprints,m_cnxHFConn) THEN // Only file used by this .NET dll
			gm_bIsConnected = True
			gm_iNbrRecords = HNbRec(Fingerprints)    
			gm_bIsConnected = False
			gm_sDataPath = sValue
		END
	END
END
PROCEDURE PUBLIC p_sTestString()
RESULT m_sTestString

PROCEDURE PUBLIC p_sTestString(par_Value is string)
m_sTestString = par_Value

PROCEDURE Constructor()
// Set public property to indicate HF is connected
//gm_sDataPath = fDataDir()  // This does not work as fDataDir unique to WinDev
gm_sDataPath = fCurrentDir()
m_cnxHFConn..Provider=hAccessHF7
m_cnxHFConn..Password = &quot;&quot;
m_cnxHFConn..Source=fDataDir()  //+&quot;\Fingerprints.fic&quot; 
IF HOpenConnection(m_cnxHFConn) THEN 
	IF HChangeConnection(Fingerprints,m_cnxHFConn) THEN // Only file used by this .NET dll
		gm_bIsConnected = True
		gm_iNbrRecords = HNbRec(Fingerprints)    
		gm_bIsConnected = False
	END
END
RESULT gm_bIsConnected
PROCEDURE Destructor()
// NOTE - This code causes AccessViolationException
//if gm_bIsConnected then
//	HCloseConnection(m_cnxHFConn)
//END

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] GetNextFingerprint (&lt;ID&gt; is int, &lt;iAccountsID&gt; is int, &lt;iDistrictStudentNbr&gt; is int, &lt;aFeatures&gt;)
//
// Parameters:
//	ID (int): Fingerprints ID
//	iAccountsID (int): AccMeals account identifier
//	iDistrictStudentNbr (int): Unique identifier of student
//	aFeatures: Template data
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
//PROCEDURE GetNextFingerprint(LOCAL ID is int, LOCAL iAccountsID is int, LOCAL iDistrictStudentNbr is int, LOCAL aFeatures is array of byte ) 
PROCEDURE GetNextFingerprint(ID is int, iAccountsID is int, iDistrictStudentNbr is int, aFeatures) // is array of byte )
bResult is boolean = HReadNext(Fingerprints,ID,hLockNo)
IF bResult THEN
	ID = Fingerprints.ID
	iAccountsID = Fingerprints.AccountsID
	iDistrictStudentNbr = Fingerprints.DistrictStudentNbr
	IF Fingerprints.Features..Null = False THEN  
		 //		aFeatures = Fingerprints.Features
		Deserialize(aFeatures,Fingerprints.Features,psdBinary)
	END
END
RESULT bResult
//result gm_bIsConnected

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] GetTestString ()
//
// Parameters:
//	None
// Return Value:
// 	string: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE GetTestString()
RESULT m_sTestString

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//SetTestString (&lt;sValue&gt; is string)
//
// Parameters:
//	sValue (string): &lt;specify the role of value&gt;
// Return Value:
// 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE SetTestString(LOCAL sValue is string)
m_sTestString = sValue


//PROCEDURE GetFirstFingerprint(local ID is int, LOCAL iAccountsID is int, LOCAL iDistrictStudentNbr is int, LOCAL aFeatures is array of byte )
PROCEDURE GetFirstFingerprint(ID is int, iAccountsID is int, iDistrictStudentNbr is int, aFeatures) // is array of byte )
bResult is boolean = HReadFirst(Fingerprints)
IF bResult THEN
	ID = Fingerprints.ID
	iAccountsID = Fingerprints.AccountsID
	iDistrictStudentNbr = Fingerprints.DistrictStudentNbr
	IF Fingerprints.Features..Null = False THEN 
//		aFeatures = Fingerprints.Features
		Deserialize(aFeatures,Fingerprints.Features,psdBinary)
	END
END
RESULT bResult
// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] WriteData (&lt;iAccountsID&gt; is int, &lt;iDistrictStudentNbr&gt; is int, &lt;sFingerID&gt; is string, &lt;aTemplate&gt; is array)
//
// Parameters:
//	iAccountsID (int): &lt;specify the role of siAccountsID&gt;
//	iDistrictStudentNbr (int): &lt;specify the role of siDistrictStudentNbr&gt;
//	sFingerID (string): &lt;specify the role of sFingerID&gt;
//	aTemplate (array): &lt;specify the role of bufFeatures&gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
//PROCEDURE WriteData(iAccountsID is int, iDistrictStudentNbr is int, sFingerID is string, aFeatures is array of byte  )  // This causes &quot;ref &lt;parm&gt;&quot; calls

PROCEDURE WriteData(LOCAL iAccountsID is int, LOCAL iDistrictStudentNbr is int, LOCAL sFingerID is string, LOCAL aTemplate is array of 1-byte unsigned int )

bSuccess is boolean = False
HReset(Fingerprints)
Fingerprints.AccountsID = iAccountsID
Fingerprints.DistrictStudentNbr = iDistrictStudentNbr
Fingerprints.FingerID = sFingerID
//Serialize(aFeatures,Fingerprints.Features,psdBinary)
//Fingerprints.Features = aTemplate  // just puts address in binary field
bufTemplate is Buffer
Serialize(aTemplate,bufTemplate,psdBinary)
Fingerprints.Features = bufTemplate

IF HAdd(Fingerprints) THEN
	bSuccess = True
END
gm_iNbrRecords = HNbRec(Fingerprints)    // Update class info
RESULT bSuccess
// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] TestA (&lt;p1&gt; is int, &lt;p2&gt; is array)
//
// Parameters:
//	p1 (int): &lt;specify the role of p1&gt;
//	p2 (array): &lt;specify the role of p2&gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE TestA(p1 is int,p2 is array of byte)
temp is array of byte = [1,2,3]
p1 += 1
p2 = temp
RESULT True
// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] TestB (&lt;p1&gt; is int, &lt;p2&gt;)
//
// Parameters:
//	p1 (int): &lt;specify the role of p1&gt;
//	p2: &lt;specify the role of p2&gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE TestB(p1 is int, p2)
temp is array of byte = [2,3,4,5]
p1 += 1
p2 = temp
RESULT True


// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] TestC (&lt;p1&gt; is int [, &lt;p2&gt; is array])
//
// Parameters:
//	p1 (int): &lt;specify the role of p1&gt;
//	p2 (array - default value=0): &lt;specify the role of p2&gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE TestC(p1 is int,p2 is array of 1-byte unsigned int = Null)
temp is array of byte = [10,11,12]
p1 += 1
IF MyParameters..NbReceived = 2 THEN
	p2 = temp
	RESULT True
ELSE
	RESULT False
END

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] TestD (&lt;p1&gt; is int, &lt;p2&gt; is COMObject)
//
// Parameters:
//	p1 (int): &lt;specify the role of p1&gt;
//	p2 (COMObject): &lt;specify the role of p2&gt;
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
//	p1 (int): &lt;specify the role of p1&gt;
//	p2 (array - default value=0): &lt;specify the role of p2&gt;
PROCEDURE TestD(p1 is int, p2 is COMObject)
temp is array of byte = [13,14,15]
p1 += 1
IF MyParameters..NbReceived = 2 THEN
	p2 = temp
	RESULT True
ELSE
	RESULT False
END

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] GetDataPath ()
//
// Parameters:
//	None
// Return Value:
// 	string: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE GetDataPath()
RESULT p_sDataPath

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//SetDataPath (&lt;sValue&gt; is string)
//
// Parameters:
//	sValue (string): &lt;specify the role of sValue&gt;
// Return Value:
// 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE SetDataPath(LOCAL sValue is string)
p_sDataPath = sValue

// Summary: &lt;specify the procedure action&gt;
// Syntax:
//[ &lt;Result&gt; = ] CloseDB ()
//
// Parameters:
//	None
// Return Value:
// 	boolean: // 	None
//
// For instance:
// Indicate an example.
//
PROCEDURE CloseDB()
IF HCloseConnection(m_cnxHFConn) THEN
	gm_bIsConnected = False
END
RESULT gm_bIsConnected</pre>
<br />
<b>C# code</b><br />
<pre class="bbcode">
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Neurotec.Biometrics;
using Neurotec.Licensing;
using WL;


namespace Test_CS
{
    public partial class FormTest : Form
    {
        public FormTest()
        {
            InitializeComponent();
        }
        private string pathTestData = @&quot;D:\BioMetrics\Test_Data&quot;;

        private void buttonOLE_Click(object sender, EventArgs e)
        {
            /*
            Connection to a HyperFileSQL Classic database without specifying the analysis:
                Provider=PCSOFT.HFSQL;Initial Catalog=c:\My HyperFileSQL Database
            Connection to a HyperFileSQL Classic database byspecifying the analysis:
                Provider=PCSOFT.HFSQL;Data Source=c:\My HyperFileSQL Database\MyAnalysis.wdd;Initial Catalog=c:\My HyperFileSQL Database
            Connection to a HyperFileSQL Client/Server database:
                Provider=PCSOFT.HFSQL;Data Source=serverdb.mycompany.fr:4910;User ID=admin;Password=secret;Initial Catalog=MyDatabase
            Connection to a HyperFileSQL Client/Server database with password-protected files that use the Russian character set:
                Provider=PCSOFT.HFSQL;Data Source=serverdb.mycompany.fr;User ID=user;Initial Catalog=MyRussianDatabase;Extended Properties=&quot;Password=*:secret1;Password=File2:secret2;Language=KOI8-R&quot;
            Note: In this example, all the database files are protected by the &quot;secret1&quot; password except for the &quot;File2&quot; file that is protected by the &quot;secret2&quot; password.
            */

            textOLE.Text = &quot;&quot;;
            try
            {
                System.Data.OleDb.OleDbConnection myOleDb = new System.Data.OleDb.OleDbConnection
                    (@&quot;Provider=PCSOFT.HFSQL;Data Source=D:\BioMetrics\\VF_CS_Test\\VF_CS_Test.wdd;Initial Catalog=&quot;+pathTestData+&quot;;&quot;); //D:\\BioMetrics\\WD_Net\\Exe;&quot;);
                    //(&quot;Provider=PCSOFT.HFSQL;Data Source=D:\\BioMetrics\\VF_CS_Test\\VF_CS_Test.wdd;Initial Catalog=D:\\BioMetrics\\VF_CS_Test\\exe:&quot;);
                    // (Provider=PCSOFT.HFSQL;Data Source=c:\My HyperFileSQL Database\MyAnalysis.wdd;Initial Catalog=c:\My HyperFileSQL Database); 
                    //(&quot;Provider=PCSOFT.HFSQL;Data Source=c:\\My HyperFileSQL Database\\MyAnalysis.wdd;Initial Catalog=c:\\My HyperFileSQL Database&quot;);
                myOleDb.Open();
                // Specify the Query
                OleDbCommand MyQuery = new OleDbCommand(&quot;SELECT ID,AccountsID,DistrictStudentNbr,FingerID,Features FROM FingerPrints&quot;,myOleDb);
                // Run the Query
                //OleDbDataReader MyData = MyQuery.ExecuteReader();
                // Read first
                OleDbDataReader MyDataReader = MyQuery.ExecuteReader();
                //MyDataReader.Read();
                // Display
                //textOLE.AppendText(MyDataReader.ToString());
                for (int i = 1; i &lt; 15; i++)
                {
                    if (MyDataReader.Read())
                    {
                        var ID = MyDataReader.GetValue(0);
                        var accountID = MyDataReader.GetValue(1);
                        var districtStudentNbr = MyDataReader.GetValue(2);
                        var fingerID = MyDataReader.GetValue(3);
                        var features = MyDataReader.GetValue(4);
                        // Display
                        textOLE.AppendText(string.Format(&quot;ID={0},AccountID={1},FingerID={2},FeaturesType={3}\n &quot;,ID.ToString(),accountID.ToString(),fingerID,features.GetType()));
                    }
                    else
                    {
                        textOLE.AppendText(&quot;EOF&quot;);
                        break;
                    }
                }
                // Close
                MyDataReader.Close();
                myOleDb.Close();
        
            }
            catch(Exception ex)
            {
                textOLE.AppendText(&quot;Error in connect: \n&quot; + ex.Message);
            }
        }
 
        private void buttonMDB_Click(object sender, EventArgs e)
        {
            textMDB.Text = &quot;&quot;;
            try
            {
                System.Data.OleDb.OleDbConnection myMDB = new System.Data.OleDb.OleDbConnection
                    (&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;+pathTestData+@&quot;\FPID.mdb;&quot;); //  D:\\BioMetrics\\VF_CS_Test\\Exe\\FPID.mdb;&quot;);
                myMDB.Open();
                // Specify the Query
                OleDbCommand MyQuery = new OleDbCommand(&quot;SELECT AccountsID FROM FingerPrints&quot;,myMDB);
                OleDbCommand myCommand = myMDB.CreateCommand();
                myCommand.CommandText = &quot;FingerPrints&quot;;
                // Run the Query
                OleDbDataReader MyDataReader = MyQuery.ExecuteReader();

                for (int i = 1; i &lt; 15; i++)
                {
                    MyDataReader.Read();
                    var accountID = MyDataReader.GetValue(0);
                    // Display
                    textMDB.AppendText(accountID.ToString() + &quot;; &quot;);
                }
                // Close
                MyDataReader.Close();
                myMDB.Close();

            }
            catch (Exception ex)
            {
                textMDB.AppendText(&quot;Error in MDB: \n&quot; + ex.Message);
            }

        }

        private void buttonConvert_Click(object sender, EventArgs e)
        {

            textConvert.Text = &quot;Start of test.\n&quot;;
            try
            {
                WL.clHFAccess hfAccess = new clHFAccess();
                hfAccess.SetDataPath(@&quot;D:\Biometrics\Test_Data&quot;); 
                int _AccountsID = 0;
                int _DistrictStudentNbr = 0;
                string _FingerID;
                //byte[] _FingerPrint;
                byte[] vf42_template;
                byte[] vf63_template;
                // Data access by using a DataSet
                FPIDTestDataSetTableAdapters.Fingerprints1TableAdapter taFP1 = new FPIDTestDataSetTableAdapters.Fingerprints1TableAdapter();
                taFP1.Connection.ConnectionString = @&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\BioMetrics\Test_Data\FPID.mdb&quot;;
                FPIDTestDataSet dsFP1s = new FPIDTestDataSet(); 
                taFP1.Fill(dsFP1s.Fingerprints1);  
                textConvert.AppendText(string.Format(&quot;WD Fingerprints: {2} Data path = {0}\nAccess MDB path = {1}\n&quot;,hfAccess.GetDataPath(),taFP1.Connection.DataSource,hfAccess.gm_iNbrRecords)); 
                int iCount = 0;
                foreach (FPIDTestDataSet.Fingerprints1Row fingerprint in dsFP1s.Fingerprints1.Rows)
                {
                    iCount++;
                    //if (iCount &gt; 15) break;
                    // Convert old template to new format:
                    vf42_template = fingerprint.Features;
                    NFRecord nfrecord = new NFRecord(vf42_template);
                    vf63_template = nfrecord.Save();
                    // Write to HF
                    _AccountsID = fingerprint.AccountsID;
                    _DistrictStudentNbr = fingerprint.DistrictStudentNbr;
                    _FingerID = fingerprint.FingerID;
                    if (hfAccess.WriteData(_AccountsID, _DistrictStudentNbr, _FingerID,  vf63_template) )
                    {
                        // Message
                        textConvert.AppendText(fingerprint.AccountsID.ToString() + &quot;; &quot;);
                    }
                    else
                    {
                        textConvert.AppendText(&quot;Error: &quot;+fingerprint.AccountsID.ToString() + &quot;; &quot;);
                    }
                    nfrecord.Dispose();
                }
                textConvert.AppendText(string.Format(&quot;\nAdded {0} HF fingerprints.\n Now {1} fingerprints.&quot;,iCount,hfAccess.gm_iNbrRecords));
                hfAccess = null;
                dsFP1s.Dispose();
                taFP1.Dispose();
            }
            catch (Exception ex)
            {
                // Display the errors
                textConvert.AppendText(&quot;Error: Source = &quot; + ex.Source + &quot;\n&quot;);
                textConvert.AppendText(&quot;Error: Message = &quot; + ex.Message + &quot;\n&quot;);
            }
            
            textConvert.AppendText(&quot; End of test.&quot;);
        }

        private void buttonDataSet_Click(object sender, EventArgs e) // Read Access with dataset
        {
            textDataSet.Text = &quot;&quot;;
            try
            {
                // Data access by using a DataSet
                //FPIDDataSetTableAdapters.FingerprintsTableAdapter ctaFPID = new FPIDDataSetTableAdapters.FingerprintsTableAdapter;
                //FPIDDataSet
                FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter taFP = new FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter();
                FPIDDataSet_MDB dsFPs = new FPIDDataSet_MDB();
                taFP.Fill(dsFPs.Fingerprints);
                int iCount = 0;
                foreach (FPIDDataSet_MDB.FingerprintsRow fingerprint in dsFPs.Fingerprints.Rows)
                {
                    iCount++;
                    if (iCount &gt; 15) break;
                    textDataSet.AppendText(fingerprint.AccountsID.ToString() + &quot;; &quot;);
                }
            }
            catch (OdbcException eExcpt)
            {
                // Display the errors
                textDataSet.AppendText(&quot;Error: Source = &quot; + eExcpt.Source);
                textDataSet.AppendText(&quot;Error: Message = &quot; + eExcpt.Message);
                //Console.WriteLine(&quot;Source = &quot; + eExcpt.Source);
                //Console.WriteLine(&quot;Message = &quot; + eExcpt.Message);
            }
        }

        #region Comments and code showing limitations of PC Soft data access 
  /* Note the code below gets the following exception: 
  * The ICommandWithParameters interface is not supported by the &#039;PCSOFT.HFSQL&#039; provider.  
  * Command parameters are unsupported with the current provider.
  *           try
            {
                // FPID Data access by using a DataSet
                FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter taFP = new FPIDDataSet_MDBTableAdapters.FingerprintsTableAdapter();
                FPIDDataSet_MDB dsFPs = new FPIDDataSet_MDB();
                taFP.Fill(dsFPs.Fingerprints);

                // .FIC access by =======================================================
                System.Data.OleDb.OleDbConnection myFIC = new System.Data.OleDb.OleDbConnection
                    (&quot;Provider=PCSOFT.HFSQL;Data Source=D:\\BioMetrics\\VF_CS_Test\\VF_CS_Test.wdd;Initial Catalog=D:\\BioMetrics\\VF_CS_Test\\exe;&quot;);
                // Experiment with making a data adapter for Insert &amp; Modify
                OleDbDataAdapter adapter = CreateDataAdapter(&quot;SELECT * FROM Fingerprints&quot;, myFIC);

                DataSet dsFIC = new DataSet();
                adapter.Fill(dsFIC);

                // Process FPID records
                int iCount = 0;
                foreach (FPIDDataSet_MDB.FingerprintsRow fingerprint in dsFPs.Fingerprints.Rows)
                {
                    iCount++;
                    if (iCount &gt; 15) break;
                    textConvert.AppendText(fingerprint.AccountsID.ToString() + &quot;; &quot;);
                    // Add to FIC Fingerprints
                   // Parameters not supported by PCSoft
                    //DataRow newFIC = dsFIC.Tables[0].NewRow();
                    //newFIC[&quot;AccountsID&quot;] = fingerprint.AccountsID;
                    //newFIC[&quot;FingerID&quot;] = fingerprint.FingerID;
                    //newFIC[&quot;DistrictStudentNbr&quot;] = fingerprint.DistrictStudentNbr;
                    //byte[] vf42_template = fingerprint.Features;
                    ////NFRecord nfrecord = new NFRecord(vf42_template);
                    ////newFIC[&quot;Features&quot;] = nfrecord;
                    //newFIC[&quot;Features&quot;] = vf42_template;
                    //dsFIC.Tables[0].Rows.Add(newFIC);
                  
                    // Try commands:
                    myFIC.Open();
                    OleDbCommand addFIC = new OleDbCommand(
                        &quot;INSERT INTO Fingerprints (AccountsID) &quot; +
                        &quot;VALUES (?)&quot;, myFIC);
                    //&quot;INSERT INTO Fingerprints (Features, FingerID, AccountsID, DistrictStudentNbr) &quot; +
                    //&quot;VALUES (?, ?, ?, ?)&quot;, myFIC);
                    OleDbParameter p1 = new OleDbParameter();
                    addFIC.Parameters.Add(p1);
                    p1.Value = fingerprint.AccountsID;
                    //fingerprint.Features, fingerprint.FingerID, fingerprint.AccountsID, fingerprint.DistrictStudentNbr);
                    //addFIC.CommandType = System.Data.CommandType.TableDirect;
                    int iAdded = addFIC.ExecuteNonQuery();
                    MessageBox.Show(&quot;Added {0} rows.&quot;, iAdded.ToString());
                }
                adapter.Update(dsFIC);
            }
            catch (OdbcException eExcpt)
            {
                // Display the errors
                textConvert.AppendText(&quot;Error: Source = &quot; + eExcpt.Source);
                textConvert.AppendText(&quot;Error: Message = &quot; + eExcpt.Message);
                //Console.WriteLine(&quot;Source = &quot; + eExcpt.Source);
                //Console.WriteLine(&quot;Message = &quot; + eExcpt.Message);
            }
        }


        public static OleDbDataAdapter CreateDataAdapter(string selectCommand,
        OleDbConnection connection)
        {
        }

           OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand, connection);

            adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

            // Create the Insert, Update and Delete commands.
            adapter.InsertCommand = new OleDbCommand(
                &quot;INSERT INTO Fingerprints (Features, FingerID, AccountsID, DistrictStudentNbr) &quot; +
                &quot;VALUES (?, ?, ?, ?)&quot;, connection);

            adapter.UpdateCommand = new OleDbCommand(
                &quot;UPDATE Fingerprints SET Features = ?, FingerID, AccountsID = ?, DistrictStudentNbr = ? &quot; +
                &quot;WHERE AccountsID = ?&quot;, connection);

            adapter.DeleteCommand = new OleDbCommand(
                &quot;DELETE FROM Fingerprints WHERE AccountsID = ?&quot;, connection);

            // Create the parameters. Add others !@!!!!!!!!!!!!!!!!!
            adapter.InsertCommand.Parameters.Add(&quot;@AccountsID&quot;,
                OleDbType.Integer, 10, &quot;AccountsID&quot;);
            adapter.InsertCommand.Parameters.Add(&quot;@DistrictStudentNbr&quot;,
                OleDbType.Integer, 10, &quot;DistrictStudentNbr&quot;);
            adapter.InsertCommand.Parameters.Add(&quot;@FingerID&quot;,
                OleDbType.VarChar, 50, &quot;FingerID&quot;);
            adapter.InsertCommand.Parameters.Add(&quot;@Features&quot;,
                OleDbType.Binary, 0, &quot;Features&quot;);

            adapter.UpdateCommand.Parameters.Add(&quot;@AccountsID&quot;,
                OleDbType.Integer, 10, &quot;AccountsID&quot;);
            adapter.UpdateCommand.Parameters.Add(&quot;@DistrictStudentNbr&quot;,
                OleDbType.Integer, 10, &quot;DistrictStudentNbr&quot;);
            adapter.UpdateCommand.Parameters.Add(&quot;@FingerID&quot;,
                OleDbType.VarChar, 50, &quot;FingerID&quot;);
            adapter.UpdateCommand.Parameters.Add(&quot;@Features&quot;,
                OleDbType.Binary, 0, &quot;Features&quot;);

            adapter.DeleteCommand.Parameters.Add(&quot;@AccountsID&quot;,
                OleDbType.Char, 5, &quot;AccountsID&quot;).SourceVersion =
                DataRowVersion.Original;
            return (adapter);
        }
*/
#endregion

        private void buttonWL_Click(object sender, EventArgs e)
        {
            //var testWL = &quot;Test&quot;;
            //var param1 = &quot;Param1&quot;;
            //clLog testLog = new clLog(ref testWL, ref param1);  

            WL.clHFAccess hfAccess = new clHFAccess();
            textWL.Text = &quot;Starting clHFAccess test.\n&quot;;
            textWL.AppendText(&quot;Data Path = &quot;+hfAccess.GetDataPath()+&quot;\n&quot;);
            textWL.AppendText(&quot;hfAccess.TestString = &quot; + hfAccess.GetTestString()+&quot;\n&quot;);
            // Read records:
            textWL.AppendText( &quot;\nStarting Records test usingg clAcess.\n&quot;); 
            textWL.AppendText(&quot;hfAccess.TestString = &quot; + hfAccess.GetTestString() + &quot;\n&quot;);
            int nbrRecords = hfAccess.gm_iNbrRecords;
            textWL.AppendText(&quot;Number of Records = &quot; + nbrRecords.ToString() + &quot;\n&quot;);
            int _ID = 0;
            int _AccountsID = 0;
            int _DistrictStudentNbr = 0;
            //var _FingerPrint = new Neurotec.IO.NBuffer(byte[]);// _Buffer);
            //NFRecord _FingerPrint = new NFRecord(); // _Buffer);
            //Neurotec.IO.NBuffer _FingerPrint;
            //byte[] _FingerPrint;
            //object _FingerPrint = new byte[100];
            //Buffer _FingerPrint;
            //byte[] _FingerPrint = new byte[100];
            //Byte[] _FingerPrint = new Byte[100];
            //try
            //{
            //    if (hfAccess.GetFirstFingerprint(ref _ID, ref _AccountsID, ref _DistrictStudentNbr,ref _FingerPrint))
            //    //if (hfAccess.GetFirstFingerprint( _ID,  _AccountsID,  _DistrictStudentNbr,  _FingerPrint)) 

            //    {
            //        do
            //        {
            //            //textWLAppendText(&quot;Processing Account: &quot; + _AccountsID.ToString()+
            //            //   &quot;, FP_Length = &quot;+_FingerPrint.Length.ToString()+ &quot;\n&quot;);
            //            textWL.AppendText(string.Format(&quot;Processing ID={0} Account: {1}, FP_Length = {2}\n&quot;, _ID, _AccountsID.ToString(),
            //              _FingerPrint.Length));
            //        }
            //        while (hfAccess.GetNextFingerprint(ref _ID, ref _AccountsID, ref _DistrictStudentNbr, ref _FingerPrint));
            //        //while (hfAccess.GetNextFingerprint( _ID, _AccountsID, _DistrictStudentNbr,  _FingerPrint));
            //    }
            //}
            //catch (Exception  ex)
            //{
            //    textWL.AppendText(&quot;Exception: &quot; + ex.Message + &quot;\n&quot;);
            //}
            //hfAccess = null;  // How to dispose? (Getting call stack error)

        }

        private void FormTest_Load(object sender, EventArgs e)
        {
 
        }

        private void buttonWL2_Click(object sender, EventArgs e)
        {
            // Test different methods of passing data from WinDev to C#
            clHFAccess wlTest = new clHFAccess();
            textWL.Text = &quot;Start of parameter test.\n&quot;;
            int testInt = 0;
            byte[] testArray = new byte[20];

            //wlTest.TestD(ref testInt,ref testArray);
            //textWL.AppendText(string.Format(&quot;Test D: testInt={0}, testArray upper bound={1}\n&quot;, testInt, testArray.GetLength(0)));

            wlTest.TestC(ref testInt, ref testArray);
            textWL.AppendText(string.Format(&quot;Test C: testInt={0}, testArray upper bound={1}\n&quot;, testInt, testArray.GetLength(0)));

            textWL.AppendText(&quot;End of test.\n&quot;);
            wlTest = null;
        }

    }
}</pre>
]]></description>
            <dc:creator>Jeff Graham</dc:creator>
            <category>WinDev Solutions</category>
            <pubDate>Thu, 15 Dec 2011 17:18:18 +0100</pubDate>
        </item>
    </channel>
</rss>
