Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Create an ODBC Driver (https://www.delphipraxis.net/86253-create-odbc-driver.html)

mohfa 11. Feb 2007 17:05


Create an ODBC Driver
 
< i'm very sorry to write in english , why in this forum : cause i have been told to post my question here in delphipraxis forum >. sorry again .

Hi every body , i have finished programming my DBMS ( a BDE replacment with my propre Table , Query , Database ) , my DBMS
uses SQL 92 .

so i want to create - write - my DBMS Driver.
i have been told to convert my DBMS pas files into C or C++ then use MVC++ to create this ODBC Driver.

could you please help me to create this ODBC Driver using Delphi .

I really need your help.

michy

Bernhard Geyer 11. Feb 2007 18:00

Re: Create an ODBC Driver
 
Why do you want to create in 2007 a ODBC-Driver?

If I use .NET i want a native ADO.NET Provider, if I use Delphi (Win32) I would like to see native TDataset-Components. No Installation of ODBC-Driver and no setup of ODBC-Entry. And for Win64 - there is no ODBC any more.

mohfa 11. Feb 2007 21:42

Re: Create an ODBC Driver
 
yes sir of course , But i was asked by 2 of my customers to give them an odbc driver for my DBMS .

really i need all ur help


regards michy

mohfa 12. Feb 2007 17:40

Re: Create an ODBC Driver
 
please is there any help.

shmia 12. Feb 2007 18:12

Re: Create an ODBC Driver
 
Do you know microsoft's ODBC documentation ?
http://msdn2.microsoft.com/en-us/library/ms709326.aspx
You need several weeks to fully understand how to write a ODBC driver.
You have to implement about 15 to 25 functions in your ODBC DLL.

mohfa 12. Feb 2007 20:06

Re: Create an ODBC Driver
 
Zitat:

Zitat von shmia
Do you know microsoft's ODBC documentation ?
http://msdn2.microsoft.com/en-us/library/ms709326.aspx
You need several weeks to fully understand how to write a ODBC driver.
You have to implement about 15 to 25 functions in your ODBC DLL.

yes sir , that's what i did the problem is with the DLL Exported Functions especiqlly with ConfigDriver and ConfigDSN functions.
so what i did :
i imlemented a unit named ODBCConst : where i declared all the Functions and this is a simple of the Unite :
Delphi-Quellcode:
function SQLAllocConnect(henv :Longint;var phdbc :Longint): Integer;
   stdcall;
function SQLAllocEnv(var phenv :Longint): Integer;
   stdcall;
function SQLAllocStmt(hdbc :Longint;var phstmt :Longint): Integer;
   stdcall;
function SQLBindCol(hstmt :Longint;icol :Word; fCType :Smallint;
   var rgbValue ;cbValueMax :Longint;var pcbValue): Integer;
   stdcall;
function SQLBindParameter(StatementHandle :Longint; ParameterNumber :Word;
   InputOutputType :Smallint; ValueType :Smallint;
   ParameterType :Smallint;
   ColumnSize :Longint; DecimalDigits :Smallint;
      ParameterValuePtr : Pointer;
   BufferLength :Longint;
      StrLen_or_IndPtr : Pointer
      ): Integer;
   stdcall;
function SQLConfigDriver(
  hwndParent: HWND;
  fRequest: WORD;
  lpszDriver: LPCSTR;
  lpszArgs: LPCSTR;
  lpszMsg: LPSTR;
  cbMsgMax: WORD;
  var pcbMsgOut: WORD): BOOL; stdcall;
 function ConfigDSN(
  hwndParent: HWND;
  fRequest: WORD;
  lpszDriver: LPCSTR;
  lpszAttributes: LPCSTR): BOOL; stdcall;
.....
ok as you see i have declared the functions SQLConfigDriver , and ConfigDSN
i export these 2 functions from the DLL File ( the ODBC Driver ), and i use a form to config the DSN the Driver is installed in the ODBC manager but the Result is :wall: so is there any thing wrong here
.

if you want i can send you my ODBC Driver and you can see or help . ,any thanks

if possible could you please send me an exe,ple of an ODBC Driver .

Regards MICHY

Union 12. Feb 2007 20:07

Re: Create an ODBC Driver
 
Therer is an PostGres driver availabe under http://www.postgresql.org/ftp/odbc/versions/src/

mkinzler 12. Feb 2007 20:10

Re: Create an ODBC Driver
 
Same for FireBird: http://sourceforge.net/project/showf...kage_id=119024

mohfa 12. Feb 2007 20:12

Re: Create an ODBC Driver
 
Zitat:

Zitat von Union
Therer is an PostGres driver availabe under http://www.postgresql.org/ftp/odbc/versions/src/

many thanks Union but this driver is written in C language and that's what i was asked to do : convert your Pas file into C then creating your ODBC Driver will be as easy as you think.

mohfa 13. Feb 2007 19:02

Re: Create an ODBC Driver
 
i'm really still for someone to help me . :cry:

mohfa 15. Feb 2007 16:52

Re: Create an ODBC Driver
 
please is there any news .


regards

marabu 15. Feb 2007 21:11

Re: Create an ODBC Driver
 
Hi Michy, welcome to Delphi-PRAXiS.

You already have studied the Microsoft Documentation for ODBC, I understand. You also have implemented the required functions, but your first test failed. How do you test? Do you make good use of the Microsoft ODBC Test Program?

A fully implemented v3 ODBC Driver is by no means a small project. Perhaps you should try to isolate small problem areas to attract more helpers. As soon as you focus on some detail, even members without explicit knowledge about ODBC drivers might be able to proof read your code.

If you don't trust your own translation of the C header files you could give Dr. Bob's HEADCONV utility a try.

Kind Regards

marabu

mohfa 16. Feb 2007 06:52

Re: Create an ODBC Driver
 
I hope if someone can provide me with a Simple DLL ( ODBC Driver ) with it's source code , and especially the declarations of exported Functions .

Michy

Reinhard Kern 16. Feb 2007 12:54

Re: Create an ODBC Driver
 
Zitat:

Zitat von mohfa
I hope if someone can provide me with a Simple DLL ( ODBC Driver ) with it's source code , and especially the declarations of exported Functions .

Michy

Hello,

if you expect to get a sample source with a ODBC driver written in Delphi - i believe that such a driver does not exist. Most programmers (including myself) will study MS documentation and header files and so on and come to the conclusion, that it is senseless to convert all this stuff to Pascal, while the job could be done directly in C/C++. Maybe you do not believe this, but this does not change the reality.

To be exact: i am sure, that it is possible to write ODBC drivers in Delphi, and i am equally sure, that it is absolutely senseless. And i am sure that i am not alone with this opinion.

SY Reinhard

mohfa 16. Feb 2007 13:04

Re: Create an ODBC Driver
 
OK thank you Reinhard Kern , let's suppose it's - a Little bit-impossible to build my DBMS ODBC Driver using Delphi so what shoud i do :
Should i convert all My DBMS Pas Files into C++ or what ?
is it so hard to build ( i mean my DBMS ODBC Driver )it with C++ ?
-- i have succedded in Translating ( Conversion ) of SQL.H , and the ODBC wraper into Pas file as you can see in my SImple Unite .
could you please expliane me more especially about the 1st question ,

many thanks

michy

mkinzler 16. Feb 2007 13:21

Re: Create an ODBC Driver
 
Not in the whole . He pointed out that you should implement the ODBC-Driver in c/c++.

mohfa 16. Feb 2007 14:43

Re: Create an ODBC Driver
 
Zitat:

Zitat von mkinzler
Not in the whole . He pointed out that you should implement the ODBC-Driver in c/c++.

Believe me and sorry of that , all what i want to know is : should i convert all my DBMS pas Files into C , C++ or what , or is there any other issue or matter that i must understand .
Could you explaine me what are pointing on :roll:

if it's a matter of ODBC needed File like Sql.H ... we can translate them into Pas files ,
my problem is in synchronising between the exported Function in the DLL file and the other Units .

marabu 16. Feb 2007 16:52

Re: Create an ODBC Driver
 
Hi mohfa,

you want to know if you can implement your ODBC driver using Delphi instead of C(++)? So rest assured and have a look at this implementation done by Gerrit Moeller: GM Interbase ODBC Driver.

I'm not sure what your other problems are, but maybe they are gone after you had a peek at the code.

Regards

Reinhard Kern 17. Feb 2007 16:13

Re: Create an ODBC Driver
 
Zitat:

Zitat von mohfa
...
Should i convert all My DBMS Pas Files into C++ or what ?
...

Hello, maybe i do not understand your problem at all. From the time on when there appeared programmable objects like the first microprocessors i used mixed language programming, C and Assembler, Delphi + Assembler + C, or whatever ist necessary. We all use today Delphi + C/C++, since Win32 API is written in C/C++ and it is definded in C/C++. It is really impossible to write a single language software, so mixed language cannot be a problem at all!

Of course you need not to port your software to C/C++ - you just use it from your driver written in C/C++. To give a simple example: there is surely a function to read a record from the database, and surely the ODBC driver needs this function at a certain point. The functionality of "ReadRecord" remains defined by Pascal if you have decided so in the past. Your newly created driver just calls this function - it does not really matter if from a Delphi or a C environment; between DLLs the language is not important and for direct calls you need some knowhow about calling conventions.

But, as i said, maybe i dont understand anything.

SY Reinhard

mohfa 19. Feb 2007 09:31

Re: Create an ODBC Driver
 
hello again .
i want to know where should i declare my Dataset in mean i which Unite is it in : OdbcInst , OdbcConst


Regards

marabu 19. Feb 2007 09:57

Re: Create an ODBC Driver
 
Hi mohfa,

neither ODBCInst nor ODBCConst seem to be proper names for Units that contain your BDE replacement components. Judging by name both Units could be part of your ODBC driver implementation. You could base your architectural decisions on a close study of the Units DB and DBTables. One thing is for sure: There should not be much dependency between your components and your driver.

Regards

mohfa 19. Feb 2007 10:08

Re: Create an ODBC Driver
 
Zitat:

Zitat von marabu
Hi mohfa,

neither ODBCInst nor ODBCConst seem to be proper names for Units that contain your BDE replacement components. Judging by name both Units could be part of your ODBC driver implementation. You could base your architectural decisions on a close study of the Units DB and DBTables. One thing is for sure: There should not be much dependency between your components and your driver.

Regards

OK as for you what is the appropriate place to decalre my Dataset or i should not declare it but use DBTABLES and DB unites .

marabu 19. Feb 2007 10:52

Re: Create an ODBC Driver
 
As I understand the given (Borland) architecture you will have your own components (TMohfaDataSet e.a.) in a Unit named MOHFADB - to distinguish it from ADODB and others. Your TMohfaDataset should be derived from TCustomMohfaDataSet which in turn should inherit directly from TDataSet. Your task is to implement the abstract methods from TDataSet in your own class TCustomMohfaDataset and to publish a compatible (see TADODataset) set of properties in your class TMohfaDataset. Please make good use of the sources that came with your Delphi Enterprise Edition and make sure you read the relevant chapters in the documentation.

Regards

Reinhard Kern 19. Feb 2007 13:28

Re: Create an ODBC Driver
 
Zitat:

Zitat von marabu
As I understand the given (Borland) architecture you will have your own components (TMohfaDataSet e.a.) in a Unit named MOHFADB - to distinguish it from ADODB and others. Your TMohfaDataset should be derived from TCustomMohfaDataSet which in turn should inherit directly from TDataSet. Your task is to implement the abstract methods from TDataSet in your own class TCustomMohfaDataset and to publish a compatible (see TADODataset) set of properties in your class TMohfaDataset. Please make good use of the sources that came with your Delphi Enterprise Edition and make sure you read the relevant chapters in the documentation.

Regards

Hello marabu, are you sure that creating a custom TDataSet results in a generally usable ODBC-driver? I think this was the original question.

SY Reinhard

marabu 19. Feb 2007 14:26

Re: Create an ODBC Driver
 
Hi Reinhard,

it wasn't me who started to write about TDataSet in the first place, but I think it is necessary anyway. I most certainly never did suggest to write a TDataSet-Successor in order to implement an ODBC-Driver.

The original poster has informed us about his own implementation of an SQL-92 based (local) RDBMS by means of TTable, TQuery, TDatabase. Just to recap: He is looking for a way to present an ODBC driver to his client, so that other tools cann access the data, too.

My suggestion to Mohfa is to start reading all the readily available documentation to learn about the architecture, so his components fit in nicely. At this moment he seems to mix up the two concepts (data-aware component vs. ODBC driver) badly. Even when local data access is implemented directly by his components, he will never succeed with his ODBC driver by trying to repackage his components. The first task should be to sort out the functionality that comprises a solid call level interface to his RDBMS. The CLI can then serve as the basis for the ODBC driver - and for the components as well.

Regards

mohfa 19. Feb 2007 19:11

Re: Create an ODBC Driver
 
Hi marabu
Zitat:

Zitat von marabu
At this moment he seems to mix up the two concepts (data-aware component vs. ODBC driver) badly. Even when local data access is implemented directly by his components, he will never succeed with his ODBC driver by trying to repackage his components. The first task should be to sort out the functionality that comprises a solid call level interface to his RDBMS. The CLI can then serve as the basis for the ODBC driver - and for the components as well.

first i'm not trying to repackage my components , cause every thing goes well with the components and even the output File(s) all what i'm trying to do is to implement my Main RDMS unit to the ODBC Driver and i think that's what should i do otherwise how this ODBC Driver will recognise is it working with my RDBMS and not an other RDBMS and because the ODBC Driver is based only on the SQL functions .

regards.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:10 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz