Page 1 of 1

Help :-( (Firebird / AdoRdd)

PostPosted: Tue May 05, 2009 11:50 pm
by Jeff Barnes
Hi,

I think I have become my own worst enemy :oops:

I have been looking at sqlwin, sqlrdd and adordd and now I am lost ... everything is starting to mix together :(

I have created a file called Fusion.gdb (firebird)
In Fusion.gdb I have a table called "Patients"

Can someone please help me connect to the database using adordd ? or SqlWin ?

I was able to connect to fusion.gbd with SQLRDD demo but I was never able to open "patients" and the cost is quite high.

I can open and view the "patients" table using IBEasy+ so I know the database is good.

Re: Help :-(

PostPosted: Wed May 06, 2009 12:01 am
by Armando
Jeff:

If the Spanish language it doesn't matter for you, Have a look to my blog

http://sqlcmd.blogspot.com/

You'll find the basic steps to start with MySql & ADO. Btw ADO it's free, you have it in xHarbour.

And have a look the next link too.

http://connectionstrings.com/sql-server-2005

Best regards

Re: Help :-(

PostPosted: Wed May 06, 2009 1:15 am
by Jeff Barnes
Thanks for the links Armando, however, I need to connect to Firebird not MySql.
(also I do not speak Spanish :wink: )

Re: Help :-(

PostPosted: Wed May 06, 2009 1:33 am
by Armando
Jeff:

Have a look to this link

http://connectionstrings.com/firebird

Regards

Re: Help :-(

PostPosted: Wed May 06, 2009 3:37 am
by Jeff Barnes
I have installed MySql and have tried the following:

Code: Select all  Expand view
USE \FusionEMR\Data\Fusion.gdb VIA "ADORDD" TABLE "PATIENTS" MYSQL FROM "127.0.0.1" USER "fusion" PASSWORD "fusion"


When I launch my app I get this Error on the above line:

Error description: Error BASE/1003 Variable does not exist: S_CTABLENAME
Called From: adordd.prg=> ADO_OPEN(212)
Called From: => DBUSEAREA(0)
Called From: fusion.prg => OPENFILES(254)


At the top of my app I have:
#include "adordd.ch"
REQUEST ADORDD

NOTE:
I had to rebuild adordd.prg to match my version of xharbour ... I found some old instructions to create an OBJ from the prg so I have adordd.obj linked in instead of a LIB file. I don't know if it make any difference.

Re: Help :-(

PostPosted: Wed May 06, 2009 4:33 am
by dutch
Dear Jeff,

This sample works fine.
Code: Select all  Expand view
// Testing LOCATE and CONTINUE
#include "FiveWin.ch"
#include "adordd.ch"

REQUEST ADORDD

function Main()
// databae on web
   USE support VIA "ADORDD" TABLE "hotel" MYSQL ;
      FROM "www.easyfo.com" USER "user" PASSWORD "password"
/*
  // database on local disk
   USE php362 VIA "ADORDD" TABLE "SUPPORT_TOPIC" MYSQL ;
      FROM "localhost" USER "root" PASSWORD "password"
*/


   browse()

   USE

return nil


Regards,
Dutch

Re: Help :-(

PostPosted: Wed May 06, 2009 2:18 pm
by Jeff Barnes
I give up.

It looks like I need to stick with FireBird and I just can not get a connection. :?

Re: Help :-( (Firebird / AdoRdd)

PostPosted: Thu May 07, 2009 12:34 pm
by Jeff Barnes
Can anyone tell me if you can access a Firebird database via Adordd and use the standard xbase commands or am I going in the wrong direction?

I have tried a number of things and still have no luck.

Please, could someone please provide some sample code showing how to connect and "USE" a firebird database.

Re: Help :-( (Firebird / AdoRdd)

PostPosted: Thu May 07, 2009 7:44 pm
by Rimantas
Jeff Barnes wrote:Can anyone tell me if you can access a Firebird database via Adordd and use the standard xbase commands or am I going in the wrong direction?

I have tried a number of things and still have no luck.

Please, could someone please provide some sample code showing how to connect and "USE" a firebird database.


Jeff ,

Do you have an "data provider" to FireBird database ? Did you installed such things ? Like this - http://www.ibobjects.com/Ole_db.html ? You can't to connect to FireBird db through Ado if in yours computers doesn't exist OleDb drivers ...

Re: Help :-( (Firebird / AdoRdd)

PostPosted: Thu May 07, 2009 8:43 pm
by Jeff Barnes
Hi Rimantas,

I have installed this:
http://www.ibphoenix.com/main.nfs?a=ibp%20...%20bp_60_odbc

It is an ODBC driver (I have also created an entry in my data sources in the windows control panel)

Do I also need to install the driver from your link?

Also, can you provide a code sample so I can see how to connect?


I really appreciate everyone's help on this ... this is my first shot at SQL and sadly it is not going so well right now :cry:

Re: Help :-( (Firebird / AdoRdd)

PostPosted: Thu May 07, 2009 9:02 pm
by Rick Lipkin
Jeff

ODBC is not the way to go .. you do need the Firebird ole provider to connect via ADO.. Lots of reference and examples here .. search the forum for ADO .. also http://connectionstrings.com is a great resoruce for connecting to various datanases and their syntax.

Rick Lipkin

Re: Help :-( (Firebird / AdoRdd)

PostPosted: Fri May 08, 2009 2:03 am
by hua
Hi Jeff,
So far this is what I've managed to cook up and some steps that I took in getting there.

1. Download and install Firebird server 2.0 series.

2. Download the free version of ADO driver from IBProvider
(NOTE: The free version supports up to Firebird 2.0 series only. Later versions require the commercial driver. See the list of differences here).

3. Finally FWH code that I use to do minor test.

Code: Select all  Expand view

#include "Fivewin.ch"
#include "Tcbrowse.ch"

//-------------
FUNCTION MAIN()

    LOCAL oRs, oErr
    local cConnStr := 'Provider=LCPI.IBProvider.3.Free;'+;
                  'Password=masterkey;User ID=sysdba;auto_commit=true;'+;
                  'Data Source=localhost:c:\employee.fdb;ctype="";dbclient_library=""'
    local oCon := CreateObject("ADODB.Connection")
    oCon:ConnectionString := cConnStr

    TRY
        oCon:Open()
    CATCH
        ShowAdoError(oCon)
        RETURN NIL
    END TRY

    oRs := CreateObject('ADODB.RecordSet')
    oRs:CursorLocation := 3
    TRY
      *oCon:BeginTrans()
      oRs:Open("SELECT CUSTOMER FROM CUSTOMER", oCon, 1, 3)
      *oCon:CommitTrans()
    CATCH
      ShowADOError(oCon)
    END

    msginfo("about to view")
    ? ors:fields("CUSTOMER"):value

    WBROWSERECORDSET( oRs )
    TCBROWSERECORDSET( oRs )

    oRs:Close()
    oCon:close()
    RETURN NIL


STATIC FUNCTION WBROWSERECORDSET( oRs )

    LOCAL oDlg, oBrw, nRec

    DEFINE DIALOG oDlg SIZE 300, 300

    @ 0, 0 LISTBOX oBrw FIELDS oRs:Fields( "CUSTOMER" ):Value;
           HEADERS "CLIENTI";
           ON RIGHT CLICK ( nRec := oRs:AbsolutePosition,;
                            oBrw:Report( "TWBrowse report", .T. ),;
                            oRs:MoveFirst(),;
                            oRs:Move( nRec - 1 ) )

    oBrw:bLogicLen = { || oRs:RecordCount }
    oBrw:bGoTop    = { || oRs:MoveFirst() }
    oBrw:bGoBottom = { || oRs:MoveLast() }
    oBrw:bSkip     = { | nSkip | Skipper( oRs, nSkip ) }
    oBrw:cAlias    = "ARRAY"

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    RETURN NIL


STATIC FUNCTION TCBROWSERECORDSET( oRs )

    LOCAL oDlg, oBrw, oCol, nRec

    DEFINE DIALOG oDlg SIZE 300, 300

    @ 0, 0 BROWSE oBrw;
           ON RIGHT CLICK ( nRec := oRs:AbsolutePosition,;
                            oBrw:Report( "TWBrowse report", .T. ),;
                            oRs:MoveFirst(),;
                            oRs:Move( nRec - 1 ) )

    ADD COLUMN TO oBrw;
               DATA oRs:Fields( "customer" ):Value;
               HEADER "CLIENTI"

    oBrw:lCellStyle = .T.

    oBrw:bLogicLen = { || oRs:RecordCount }
    oBrw:bGoTop    = { || oRs:MoveFirst() }
    oBrw:bGoBottom = { || oRs:MoveLast() }
    oBrw:bSkip     = { | nSkip | Skipper( oRs, nSkip ) }
    oBrw:cAlias    = "ARRAY"

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    RETURN NIL


STATIC FUNCTION SKIPPER( oRs, nSkip )

    LOCAL nRec := oRs:AbsolutePosition

    oRs:Move( nSkip )

    IF oRs:EOF; oRs:MoveLast(); ENDIF
    IF oRs:BOF; oRs:MoveFirst(); ENDIF

    RETURN oRs:AbsolutePosition - nRec

STATIC FUNCTION ShowAdoError(oCon)

LOCAL   nAdoErrors   := 0
LOCAL   oAdoErr

      nAdoErrors   :=  oCon:Errors:Count()
      IF nAdoErrors > 0
         oAdoErr      := oCon:Errors(nAdoErrors-1)
         msginfo( oAdoErr:Description + CRLF + oAdoErr:Source )
      ELSE
         msginfo( 'Not Oracle Error' )
      ENDIF

RETURN nil
 


There are a few ADO stuffs that I collected from the forum and posted it in one place here (http://wiki.fivetechsoft.com/doku.php?i ... ted_stuffs)