FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV Mobile 2024
→
Carga Txt To Sql
Carga Txt To Sql
Débuté par adrianoboller, 18 nov. 2014 13:49 - 1 réponse
Connectez-vous…
adrianoboller
#1
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 13:49
Procedure
DB_CargaTxt2Sql
(
LOCAL
ArquivoTxt
,
LOCAL
TabelaSQL
,
LOCAL
Excluir
,
LOCAL
Debug
)
// Finalidade é ler um txt que se encontra na raiz do aplicativo e importar os dados para a base de dados do aplicativo android como carga inicial.
// Declara as variaves
IdFile
,
ResCloseFile
,
FileID
,
NumeroLinha is
int
Line is
string
Resultado is
boolean
QRYSQL is
Data Source
//Verifica se existe o arquivo
PathFile is
string
=
fDataDir
(
) + [
"\"
] +
ArquivoTxt
IF
NOT
fFileExist
(
PathFile
)
THEN
Close
(
)
END
//Abrir arquivo txt
FileID
=
fOpen
(
PathFile
,
foReadWrite
)
IF
IdFile
= -
1
THEN
NextTitle
(
"Atenção"
)
Error
(
ErrorInfo
(
errMessage
)
)
ELSE
//Converte de Unicode para Ansi
Line
=
UnicodeToAnsi
(
fReadLine
(
FileID
)
)
//Limpa Base de dados
IF
Excluir
=
"S"
THEN
Resultado
=
HExecuteSQLQuery
(
QRYSQL
,
"Delete from "
+
TabelaSQL
)
IF
Resultado
=
True
AND
TabelaSQL
<
>
""
THEN
IF
Debug
=
"S"
THEN
NextTitle
(
"Atenção"
)
Info
(
"Tabela "
+
TabelaSQL
+
" inicializada."
)
END
END
END
//Leitura do Arquivo
//Linha 1 = OBS do Arquivo Finalidade da Carga
NumeroLinha
=
0
WHILE
Line
<
>
EOT
AND
Line
<
>
""
//Proxima linha
NumeroLinha
+
=
1
Line
=
fReadLine
(
FileID
)
IF
Debug
=
"S"
THEN
Info
(
"Linha:"
+
NumeroLinha
,
Line
)
END
//Insere os dados do arquivo texto na Nova Base de Dados
Resultado
=
HExecuteSQLQuery
(
QRYSQL
,
Line
)
IF
Resultado
=
False
AND
Line
<
>
""
AND
Length
(
Line
) >
3
THEN
NextTitle
(
"Atenção"
)
Info
(
"Erro no arquivo de carga!..."
,
Line
)
ELSE
IF
Debug
=
"S"
THEN
NextTitle
(
"Atenção"
)
Info
(
"Carga da base de dados com sucesso!"
,
Line
)
Info
(
HNbRec
(
TabelaSQL
,
hStateAll
) )
END
END
END
//Final do Arquivo
IF
Debug
=
"S"
THEN
IF
Line
=
""
THEN
Error
(
ErrorInfo
(
errMessage
)
)
IF
Line
=
EOT
THEN
Info
(
"Final do Arquivo."
)
NextTitle
(
"Atenção"
)
Info
(
"Registros gravados na tabela "
+
TabelaSQL
,
HNbRec
(
TabelaSQL
,
hStateAll
)
)
END
//Fechando a leitura do Arquivo
ResCloseFile
=
fClose
(
IdFile
)
IF
ResCloseFile
=
0
THEN
IF
Debug
=
"S"
THEN
Error
(
"Arquivo fechado com sucesso!"
)
END
END
END
Signaler
0
0
adrianoboller
#2
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 24 mars 2016 - 20:45
Prezados,
Caso de problema com acentuação, use:
Esse comando chegou a testar?
retorno is string = UFT8toString(textocomacento)
USE O COMANDO UTF8ToString OU AnsiToUnicode
ProcedureWS_Android_IOS_HTTPGetResult
(
)
// Variable
buf
ResHTTP is Buffer
s
HTTPResult isstring
// Retrieves the result of the query
buf
ResHTTP
=
HTTPGetResult
(
httpResult
)
// Result in UTF8 em iOS Apple
IFIniOSMode
(
) =
TrueORIniOSSimulatorMode
(
) =
TrueORIniOSEmulatorMode
(
) =
True
IFStringCount
(
buf
ResHTTP
, “
ISO
-
8859
-
1
”
,
IgnoreCase
) =
0
THEN
s
HTTPResult
=
UTF8ToString
(
buf
ResHTTP
)
ELSE
s
HTTPResult
=
AnsiToUnicode
(
buf
ResHTTP
)
END
ELSE
IFInAndroidMode
(
) =
TrueORInAndroidSimulatorMode
(
) =
TrueORInAndroidEmulatorMode
(
) =
True
// Result in Android
s
HTTPResult
=
buf
ResHTTP
END
RESULTsHTTPResult
--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/
Signaler
0
0
→ Revenir à WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte