Welcome! Log In Create A New Profile

Advanced

[WD] C# OLEDB connect to HFSQL

Posted by Infoss 
Infoss
[WD] C# OLEDB connect to HFSQL
May 14, 2022 02:04PM
Greeting

Has anyone connected from Visual Studio C # to HFSQL database via OLEDB?

Is it complicated?

[help.windev.com]
Re: [WD] C# OLEDB connect to HFSQL
May 16, 2022 03:30PM
Hi, just to share the experience this code did the job without any problems

public static void Main(string[] args)
{
   // Déclaration de la chaîne de connexion
   string connectionString = "Provider=PCSOFT.HFSQL;Data Source=serveurbdd;" +
"User ID=admin;Initial Catalog=mabase";

   // Instancie l'objet de connexion OLE DB en passant la chaîne de connexion au constructeur
   OleDbConnection connect = new OleDbConnection(connectionString);

   // Ouvre la connexion
   connect.Open();

   // Crée et exécute une requête
   OleDbCommand cmd = new OleDbCommand("SELECT nom,prenom,IDClient from client", connect);
   OleDbDataReader reader = cmd.ExecuteReader();

   // Parcours le résultat de la requête et affiche les éléments sur la console
   while (reader.Read())
   {
       int nIDClient = reader.GetInt32(2);
       Console.WriteLine("{0} - {1} - {2}",reader.GetString(0), reader.GetString(1), nIDClient);
   }
}

[infosonline.net]
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: