|
|
|
|
- Overview
- Setup
- Configuration
- Use
ODBC on HFSQL via Visual .NET (in C#)
Available only with this kind of connection
The ODBC driver on HFSQL Classic (single-user and multi-user) is used to access an HFSQL Classic database from an external database software that supports ODBC accesses. This gives you the ability to use the ODBC driver on HFSQL Classic via Visual.NET (in C#). Setup When installing WINDEV or WEBDEV on the development computer, the ODBC driver can be installed on HFSQL Classic. Furthermore, when configuring the setup program of your WINDEV applications, you have the ability to include the setup of the ODBC driver on HFSQL. To use the ODBC driver on HFSQL, you must configure the ODBC driver: - Start the ODBC data administrator (ODBCAD32.EXE) on your computer. To do so, select "Start .. Run" from Windows and type "ODBCAD32.EXE".
- Select the "User database" tab.
- Click the "Add" button.
- Select the "HyperFileSQL Classic" driver.
- Click "Done".
- Enter the name of the HFSQL data source. This name will be used to identify the HFSQL database in the external programs.
- Click the "Details" button.
- Click "Browse" to select the WDD file corresponding to the analysis.
- In the list of analyses, select the requested analysis and the directory of the data files ("Browse" button). All the HFSQL data files corresponding to the selected analysis are grouped in this directory.
Caution: a file directory must be selected for each analysis. - Validate ("OK" button).
The database can be used in read/write from the external programs via the ODBC driver on HFSQL Classic. Example of code used to handle the ODBC driver on HFSQL from your Visual .NET program: -------------------------------------------------------------------- // Sample code for using an HFSQL database by ODBC namespace ConsoleApplicationTestODBC { class Sample { public static void Main() { try { // Connection by using a DSN // MyODBCDatabase is an ODBC data source defined with odbcad32 // OdbcConnection nwindConn = new OdbcConnection("DSN=MyODBCDatabase"); // Connection by passing the connections parameters directly // ANA=<Full path of the analysis> // DIR=<Directory of the files> OdbcConnection MyConnection = new OdbcConnection("Driver={HyperFileSQL};ANA=c:\test\\MyAnalysis.wdd;DIR=c:\test\\;"); // Open the connection MyConnection.Open(); // Query that must be run on the database OdbcCommand MyQuery = new OdbcCommand("SELECT * FROM MyFile", MyConnection); // Execute query OdbcDataReader MyData = MyQuery.ExecuteReader(); // Browse the result of the query while (MyData.Read()) { Console.WriteLine("\t{0}\t{1}", MyData.GetInt32(0), MyDatas.GetString(1)); } MyData.Close(); MyConnection.Close(); } catch(OdbcException eExcpt) { // Display the errors Console.WriteLine("Source = " + eExcpt.Source); Console.WriteLine("Message = " + eExcpt.Message); } // pause before exiting Console.ReadLine(); } } } --------------------------------------------------------------------
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|