FUNCTION imp_dup()
#include "sqlrdd.ch"
#include "dbinfo.ch"
#include "mysql.ch" // Needed if you plan to use native connection to MySQL
#define RECORDS_IN_TEST 1000
#define SQL_DBMS_NAME 17
#define SQL_DBMS_VER 18
REQUEST SQLRDD // SQLRDD should be linked in
REQUEST SR_MYSQL // Needed if you plan to use native connection to MySQL
Local Areant:=Select(), vTabela:={}, vCarteira
MsgRun("Abrindo conexao com o banco de impressao.")
cConnString :="MySQL=localhost;UID=banco;PWD=senha;AUTOCOMMIT=1000;DTB=duplicata"
nDetected := DetectDBFromDSN( cConnString )
If nDetected > 0
nCnn := SR_AddConnection( nDetected, cConnString )
If nCnn < 0
Fim_Run()
MsgStop("Nao foi possivel conectar ao banco.")
Select(Areant)
Return .f.
Endif
ElSE
Fim_Run()
MsgStop("E necessario a instalacao do MYSQL.")
Select(Areant)
Return .f.
EndIf
vTabela := SR_ListTables()
vCarteira := vTabela[1]
If !SR_ExistTable(vCarteira)
MsgStop("Nao foi possivel encontrar a tabela no banco.")
SR_EndConnection(nCnn)
Select(Areant)
Return .f.
EndIf
Hw_Atualiza_Dialogo("Preparando duplicata para impressao.")
USE &vCarteira NEW SHARED VIA "SQLRDD"
Do While .t.
if travarqivo(5)
dbappend()
Replace CNPJ with RetiraCar(Empresa->CGC)
Replace Documento with Receber->Documento
Replace Codigo with Receber->Codigo
Replace Cliente with Receber->Cliente
Replace Valor with Receber->Valor
Replace Debito with Receber->Debito
Replace Emissao with Receber->Emissao
Replace Vencimento with Receber->Vencimento
Replace Nom_Vend with Receber->Nom_Vend
Replace TIPO with Receber->Tipo
dbunlock()
Else
Loop
Endif
Exit
Enddo
SR_End()
Select(Areant)
Fim_Run()
Return .t.
O erro:
Error DBCMD/1011 Alias already in use: RECEBER_DBF
Called from ->DBUSEAREA(0)
Called from vendas.prg->IMP_DUP(3776)
Called from quiosquevenda.prg->(b)QUIOSQUEVENDA(69)