Ir para conteúdo
Fórum Script Brasil

pespaim

Membros
  • Total de itens

    2
  • Registro em

  • Última visita

Tudo que pespaim postou

  1. pespaim

    Ler Txt E Gravar Mdb

    Valeu pela ajuda, mas já consegui o que queria em outro site. Segue abaixo a solução: <!--#include file="fobjvbs.inc"--> <% dim path_do_arquivo, fs, thisfile, linha_txt, Txt_matr, Txt_Nome Dim ComandoSQL, bd path_do_arquivo = Server.MapPath("assoc.txt") 'AQUI EM CIMA ESTA O NOME DO ARQUIVO QUE SERÀ LIDO response.write(path_do_arquivo) Set fs = CreateObject("Scripting.FileSystemObject") Set thisfile = fs.OpenTextFile(path_do_arquivo, forreading, False) 'response.write path_do_arquivo & nome_do_arquivo & "<BR>" Set Conexao = Server.CreateObject("ADODB.Connection") 'Conexao.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("bd\cadastro.mdb")) Conexao.Open "DSN=asberg;UID=asberg;PWD=w8d4p5g7;" While (not thisfile.AtEndOfStream) and response.isclientconnected() 'LENDO A LINHA DO TXT linha_txt = thisfile.readline Txt_matr = left(linha_txt,7) Txt_Nome = Mid(linha_txt,8,35) 'SE QUISER VISUALIZAR A LEITURA DESMARQUE O COMENTARIO ABAIXO ComandoSQL = "INSERT INTO tblCadastro (Matricula, Nome)" ComandoSQL = ComandoSQL & " VALUES (" ComandoSQL = ComandoSQL & "'" & Txt_matr & "'," ComandoSQL = ComandoSQL & "'" & Txt_Nome & "');" Set bd = Conexao.Execute(ComandoSQL) Response.write Txt_matr & " - " & Txt_Nome & "<BR>" Response.write "-----registro incluído -----------------------" & "<BR>" WEND ' Retorna o While Conexao.Close Set bd = Nothing Set Conexao = Nothing %> '-- Segue abaixo o arquivo fobjvbs.inc que deve ser salvo separado <% '=============================================================== ' Type Info: IOMode, TypeInfo Version 0.000 ' GUID: {00000000-0000-0000-0000-000000000000} ' LCID: 0X00000000 ' TypeKind: enum '--------------------------------------------------------------- ' Variable/Constant: ForReading ' Const ForReading = 1 ' Variable/Constant: ForWriting ' Const ForWriting = 2 ' Variable/Constant: ForAppending ' Const ForAppending = 8 '=============================================================== ' Type Info: Tristate, TypeInfo Version 0.000 ' GUID: {00000000-0000-0000-0000-000000000000} ' LCID: 0X00000000 ' TypeKind: enum '--------------------------------------------------------------- ' Variable/Constant: TristateTrue ' Const TristateTrue = -1 ' Variable/Constant: TristateFalse ' Const TristateFalse = 0 ' Variable/Constant: TristateUseDefault ' Const TristateUseDefault = -2 ' Variable/Constant: TristateMixed ' Const TristateMixed = -2 %>
  2. pespaim

    Ler Txt E Gravar Mdb

    Tenho um arquivo texto assim, ó: 999999AAAAAAAAAAAAA Como faço para ler o arquivo sendo que o valor numérico é o campo matrícula e o alfa é o nome. (Como gravar no MDB eu sei, preciso saber só a parte de ler o arquivo texto.) Valewz!
×
×
  • Criar Novo...