Jump to content
Fivewin Brasil

Alguém usa o activex XHbCom.HbConnection?


rochinha

Recommended Posts

Amiguinhos,

Encontrei o seguiten código, mas não acrescentei nele qualquer informação de onde, no Google não vireferência a nada. Sei que é do (x)Harbour, óbeveo!

Citar

#include "fivewin.ch"

function main()
   public conn // HbConnection
   public cust // HbTable
   public onDBF := .t. // Se .f. o acesso sera via MySQL

   aNomes      := { "JOSE","MARIA","ANTONIO","CARLOS","MANOEL","OTACILIO","RUBENS","DANILO","HEBRON" }
   aSobreNomes := { "DA SILVA","DA CRUZ","DOS SANTOS","DA COSTA","DE JESUS","SOBRINHO","FILHO","NETO","DAS DORES" }
   aSalarios   := { 500,450,680,1250,3000,1800,2200,490,950 }

   aStruct := {}
   aadd( aStruct, { "NOME"   , "C", 30, 0 } )
   aadd( aStruct, { "SALARIO", "N", 14, 2 } )
   aadd( aStruct, { "DATA"   , "D",  8, 0 } )
   if .Not. file("xbapi.dbf")
      dbCreate( "xbapi", aStruct )
   endIf

   conn := TOleAuto():New( "XHbCom.HbConnection" )
   cust := TOleAuto():New( "XHbCom.HbTable" )

   cust:Connection := conn //' associate table with connection

   If .Not. onDBF
      logRes := conn:MedLogin( "127.0.0.1", "19C8", "root", "senha", "sqlj" )
      If logRes <> 0
         MsgStop("Unable to connect to Mediator. Please check if Mediator is running and you have customized connection parameters specified in call to MedLogin function")
      EndIf
      RddDriverName := "MEDNTX"
   Else
      RddDriverName := "DBFNTX"
   EndIf

   //? len(aNomes)
   //? len(aSobreNomes)
   //? len(aSalarios)

   //cust:DbCreate( "xbapi", aStruct, RddDriverName ) // Cria xbapi.dbf

   //cust:DbCreateIndex( "xbNome", "nome" ) // Cria o indice xbNome com o campo nome

   cust:DbUseArea( RddDriverName, "xbapi.dbf" )

   //cust:DbSetIndex( "customer" )
   if Cust:Reccount < 1
      For rn = 1 To 9
          custnome    := aNomes[ Random( 9 ) ] + " " + aSobreNomes[ Random( 9 ) ]
          custsalario := aSalarios[ Random( 9 ) ]
          custdata    := Date()
          ? custnome, custsalario, custdata
          cust:DbAppend()
          cust:Value("NOME")    := custnome
          cust:Value("SALARIO") := custsalario
          cust:Value("data")    := custdata
      Next
      cust:DbCommit()
   endIf

   ? "Existem ", Cust:Reccount, " clientes:"

   If cust:NetErr
      MsgStop("Cannot open xbapi.dbf")
      return .t.
   EndIf

   //cust:DbSetIndex( "cust_rd" ) // ' order by registration date

   for i = 1 to 5 // do While .Not. cust:EOF
       MsgStop( cust:value("nome") + " Salario: " + Str(cust:value("salario")) )
       cust:DbSkip()
   next // enddo

   cust:DbCloseArea() // ' close table

return .t.

Se usou ou usa esta DLL/OCX Quais suas impressões?

Onde encontro mais exemplos de uso?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...