Dbf/cdx to sql changing

Re: Dbf/cdx to sql changing

Postby wartiaga » Fri Jul 19, 2024 12:06 pm

vilian wrote:Yes, you can. Are you using maria01.prg by this way?

oCn := maria_Connect( aStr[ 1 ], .t. )

What is aStr's content ? I think your content is out of date.


Thank you, maria01.prg it was old.
wartiaga
 
Posts: 204
Joined: Wed May 25, 2016 1:04 am

Re: Dbf/cdx to sql changing

Postby Rick Lipkin » Fri Jul 19, 2024 8:26 pm

Otto

Look in the \samples .. compile Adorick.prg and the associated .rc .. you will notice that the program creates the SQL Table "Rick.mdb" and I create the table Customer and I append 4 records .. you can certainly create more records with the code ... would be a lot of code ... I have no problem with thousands of records .. the SQL Filter code is extremely fast ..



Code: Select all  Expand view

If .not. File( cDefa+"\Rick.mdb" )

   Ferase( cDefa+"\Rick.mdb" )

   // create the adox object
   Try
      catNewDB := CreateObject("ADOX.Catalog")
   Catch
      MsgInfo( "Could not Create ADOX object")
      Return(.f.)
   End try

   // create the table Rick.mdb
   Try
     catNewDB:Create('Provider='+xProvider+';Data Source='+xSource+';Jet OLEDB:Engine Type=5' )
   Catch
     MsgInfo( "Could not create the table "+xSource )
     Return(.f.)
   End Try

   Try
     oCn  := CREATEOBJECT( "ADODB.Connection" )
   Catch
     MsgInfo( "Could not create the ADO object for connection")
   End Try

   TRY
     oCn:Open( xCONNECT )
   CATCH oErr
     MsgInfo( "Could not open a Connection to Database "+xSource )
     RETURN(.F.)
   END TRY


   cSQL := "CREATE TABLE CUSTOMER"
   cSQL += "( "
   cSQL += "[CUSTOMEREID] char(18) NOT NULL, "
   cSQL += "[LAST NAME] char(30) NULL, "
   cSQL += "[FIRST NAME] char(30) NULL, "
   cSQL += "[MID INIT] char(30) NULL, "
   cSQL += "[ADDRESS1] char(30) NULL, "
   cSQL += "[CITY] char(30) NULL, "
   cSQL += "[STATE] char(30) NULL, "
   cSQL += "CONSTRAINT PK_USERINFO PRIMARY KEY ( CUSTOMEREID )"
   cSQL += " )"

   Try
      oCn:Execute( cSQL )
   Catch
      MsgInfo( "Table CUSTOMER Failed" )
      Return(.f.)
   End try

   oCn:Close()
   oCn := nil

Endif

xLOGIN := UPPER( WNetGetuser() )+space(8) // fivewin
xLOGIN := SUBSTR(xLOGIN,1,8)

oRsCust := TOleAuto():New( "ADODB.Recordset" )
oRsCust:CursorType     := 1        // opendkeyset
oRsCust:CursorLocation := 3        // local cache
oRsCust:LockType       := 3        // lockoportunistic

// check for very first user

cSQL := "SELECT * FROM CUSTOMER"
TRY
   oRsCust:Open( cSQL, xCONNECT )
CATCH oErr
   MsgInfo( "Error in Opening CUSTOMER table here" )
   RETURN(.F.)
END TRY

If oRsCust:eof

   oRsCust:AddNew()
   oRsCust:Fields("CustomerEid"):Value  := "011111111111111111"
   oRsCust:Fields("Last Name"):Value    := "Lipkin"
   oRsCust:Fields("First Name"):Value   := "Richard"
   oRsCust:Fields("Mid Init"):Value     := "M"
   oRsCust:Fields("Address1"):Value     := "123 Anywhere"
   oRsCust:Fields("City"):Value         := "Columbia"
   oRsCust:Fields("State"):Value        := "SC"
   oRsCust:Update()

   oRsCust:AddNew()
   oRsCust:Fields("CustomerEid"):Value  := "011111111111111112"
   oRsCust:Fields("Last Name"):Value    := "Lipinsky"
   oRsCust:Fields("First Name"):Value   := "Jason"
   oRsCust:Fields("Mid Init"):Value     := "S"
   oRsCust:Fields("Address1"):Value     := "123 Arborgate"
   oRsCust:Fields("City"):Value         := "Columbia"
   oRsCust:Fields("State"):Value        := "SC"
   oRsCust:Update()

   oRsCust:AddNew()
   oRsCust:Fields("CustomerEid"):Value    := "011111111111111113"
   oRsCust:Fields("Last Name"):Value    := "Lipkin"
   oRsCust:Fields("First Name"):Value   := "Beth"
   oRsCust:Fields("Mid Init"):Value     := "  "
   oRsCust:Fields("Address1"):Value     := "123 Lake Murray Blvd"
   oRsCust:Fields("City"):Value         := "Lexington"
   oRsCust:Fields("State"):Value        := "SC"
   oRsCust:Update()

   oRsCust:AddNew()
   oRsCust:Fields("CustomerEid"):Value    := "011111111111111114"
   oRsCust:Fields("Last Name"):Value    := "Lizzarous"
   oRsCust:Fields("First Name"):Value   := "Tim"
   oRsCust:Fields("Mid Init"):Value     := "J"
   oRsCust:Fields("Address1"):Value     := "456 Broad River"
   oRsCust:Fields("City"):Value         := "Irmo"
   oRsCust:Fields("State"):Value        := "SC"
   oRsCust:Update()


Endif


// you can add many more records to the Customer table here.  The CustomerEID field is the primary key and unique.


 



Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2657
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Dbf/cdx to sql changing

Postby Otto » Fri Jul 19, 2024 9:01 pm

Hello Rick,
yes, I believe so. You are using a Microsoft Access database.

When I received the task of creating the online booking system for a vacation region in 2004, we got the job only because we had the fastest access time.
At that time, we switched from MS_SQL to JetEngine on short notice.
I was always very satisfied.
Even when I worked with VB6, I used the ACCESS database. However, when the JETENGINE was discontinued and no longer installed by hosting companies, I switched to MariaDB on the web.

But I am a visual type, and therefore I like the file system as a framework for a database and I simply want the data there and not in a container again.

I now have clear ideas on how a database should be for my purposes and have delved deeply into it. I like the DBF system, which for me is practically just a directory.
If you observe how people organize their data on the hard drive or desktop, you can see what is needed. A rigid framework is not ideal.
***
I have often thought that the ACCESS support in FIVEWIN should be much more emphasized in the advertising for FIVEWIN.
The acquisition of new customers would then proceed logically.
EXCEL -> ACCESS -> FIVEWIN

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dbf/cdx to sql changing

Postby Rick Lipkin » Sat Jul 20, 2024 1:15 pm

Otto

ADO does all the work and it is part of FW .. Rao has created a set of functions that leverage ADO .. have a look at \source\function\adofuncs.prg.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2657
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Dbf/cdx to sql changing

Postby Otto » Sat Jul 20, 2024 5:06 pm

Thank you Rick.
But I am working on an own solution now.

I have clear ideas on how a database should be for my purposes and have delved deeply into it. I like the DBF system, which for me is practically just a directory.
If you observe how people organize their data on the hard drive or desktop, you can see what is needed. A rigid framework is not ideal.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dbf/cdx to sql changing

Postby acuellar » Wed Jul 24, 2024 3:50 pm

wartiaga wrote:
nageswaragunupudi wrote:Please use this revised maria01.prg
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

static aStr := { "208.91.198.197:3306,fwhdemo,gnraofwh,Bharat@1950", ;
                 "209.250.245.152,fwh,fwhuser,FiveTech@2022" }
static oCn

function Main()

   local aTables

   SET DATE ITALIAN
   SET CENTURY ON

   FW_SetUnicode( .t. )

   CursorWait()
   oCn      := maria_Connect( aStr[ 1 ], .t. )
   aTables  := oCn:ListTables()

   XBROWSER oCn:ListTables() ;
      TITLE "Dbl-Click to View Table" ;
      SHOW RECID ;
      SETUP ( ;
      oBrw:aCols[ 1 ]:bLDClickData := { |r,c,f,o| ShowTable( o:Value ) }, ;
      oBrw:bDropFiles := { |aFiles| xbrowse( aFiles ) } )

   oCn:Close()

return nil


function ShowTable( cTable )

   local oRs, nSecs  := SECONDS()

   if cTable == "custbig"
      MsgRun( "Reading " + cTable, "Please wait", { || oRs   := oCn:RecSet( cTable, -100 ) } )
   else
      MsgRun( "Reading " + cTable, "Please wait", { || oRs   := oCn:RowSet( cTable ) } )
   endif
   nSecs    := SECONDS() - nSecs

   XBROWSER oRs TITLE cTable + " (" + cValToChar( nSecs ) + ") seconds" ;
      FASTEDIT NOMODAL SHOW RECID

return nil


Mr Rao
With oCn:= maria_Connect( aStr[ 1 ], .t. ) OK Compiling with VS2022 and mysqlclient.lib or libmariadb32.lib

For this Server "209.250.245.152,fwh,fwhuser,FiveTech@2022"
With oCn:= maria_Connect( aStr[ 2 ], .t. ) Error 2026 SSL Connection.... Compiling with VS2022 and mysqlclient.lib
With oCn:= maria_Connect( aStr[ 2 ], .t. ) Error 2019 Can't initialize character.... Compiling with VS2022 and libmariadb32.lib

I think this Error 2026 SSL Connection.... It's because of the new version of MariaBD greater than 11.4.0

Thanks for the help
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1630
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Dbf/cdx to sql changing

Postby nageswaragunupudi » Sun Jul 28, 2024 3:51 pm

First, please try building using "buildh.bat" or "buildh32.bat" in the fwh\samples folder.
Build??.bat files use the correct lib to be linked.
Both servers work.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10468
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dbf/cdx to sql changing

Postby acuellar » Mon Jul 29, 2024 7:40 pm

Thanks Mr. Rao

With libmysql32.lib and libmysql.dll works

But I need it to work with mysqlclient.lib so it doesn't use libmysql.dll. To make the EXE portable

You can try with mysqlclient.lib

Thank you very much for the help
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1630
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Dbf/cdx to sql changing

Postby nageswaragunupudi » Wed Jul 31, 2024 3:23 pm

You can try with mysqlclient.lib

This library works with msvc32 only.

Tested and working with mysqlclient.lib.

Change this line in buildh32.bat
Code: Select all  Expand view
echo %fwh%\lib\FiveH32.lib %fwh%\lib\FiveHC32.lib %fwh%\lib\libmysql32.lib  >> msvc.tmp

change this line as
Code: Select all  Expand view
echo %fwh%\lib\FiveH32.lib %fwh%\lib\FiveHC32.lib %fwh%\lib\mysqlclient.lib  >> msvc.tmp


Now test "buildh32 maria01"
Working fine.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10468
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 62 guests