import txt into database

Ask a Question related to ASP, Design and Development.

  1. #1

    Default import txt into database

    Hi,

    I still have problem to import the text file delimited by tabs or commas
    into the database.
    I refer to [url]http://www.connectionstrings.com/[/url] for the connection, ODBC
    doesn't work and OLD DB works only for csv files. Any idea? Does anybody has
    workable samples? Thanks a lot.

    ODBC
    Standard:
    "Driver={Microsoft Text Driver (*.txt;
    *.csv)};Dbq=c:\txtFilesFolder\;Extensions=asc,csv, tab,txt;"

    OLE DB
    Standard:
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended
    Properties=""text;HDR=Yes;FMT=Delimited"""

    Atse


    atse Guest

  2. Similar Questions and Discussions

    1. import a text file to database
      Hi, I am still stick on the text file being imported to database. Can anybody help? I have just done the csv format files. And then I work on...
    2. Import Data from flat-database to relational-database
      Before I start I need some tips and pleas excuse my bad english. I have two databases, one is flat and one is a relational database. example ...
    3. NEWBIE HELP Import Data from flat-database to relational-database
      I want to import Data from a simple Database, which contains all Information in one big record into a relational Database and split up the big...
    4. Parallel Database Import / Export
      Hello, I was wondering if there was a way to perform a multiple database import to improve performance on a dual cpu Solaris box? I am guessing...
    5. Parallel Database Import / Export?
      Hello, I was wondering if there was a way to perform a multiple database import to improve performance on a dual cpu Solaris box? I am guessing...
  3. #2

    Default Re: import txt into database

    Ah, are you moving your data out of the text files and migrating to a DB
    now? Outstanding! What kind of troubles are you having, and if relevant,
    what does the data in the text file look like? Also, what kind of DB are
    you importing into?

    Ray at work

    "atse" <dunggaze@yahoo.com> wrote in message
    news:P4_ib.334944$Lnr1.321256@news01.bloor.is.net. cable.rogers.com...
    > Hi,
    >
    > I still have problem to import the text file delimited by tabs or commas
    > into the database.
    > I refer to [url]http://www.connectionstrings.com/[/url] for the connection, ODBC
    > doesn't work and OLD DB works only for csv files. Any idea? Does anybody
    has
    > workable samples? Thanks a lot.
    >
    > ODBC
    > Standard:
    > "Driver={Microsoft Text Driver (*.txt;
    > *.csv)};Dbq=c:\txtFilesFolder\;Extensions=asc,csv, tab,txt;"
    >
    > OLE DB
    > Standard:
    > "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended
    > Properties=""text;HDR=Yes;FMT=Delimited"""
    >
    > Atse
    >
    >

    Ray at Guest

  4. #3

    Default Re: import txt into database

    Thanks for your coming again, Ray.
    I have just done the csv format files. And then I work on text and DAT
    formats, but I have problem to import these kinds of formats to MySQL ( and
    MS SQL)
    Please see the attachments, and the text format is changed from DAT format,
    delimited by tabs or commas. I can't select and insert them into the
    database.

    When I try:
    select * from thisfile.txt and then insert these records into a designated
    table of the database.

    the error message is:

    Microsoft JET Database Engine error '80040e14'

    Syntax error in FROM clause.

    /insertfile.asp, line 46

    ' line 46 is
    set rs = conn.execute("select * from thisfile.txt")


    Thanks again for your further help.

    Atse

    "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
    news:O$KQK5pkDHA.2080@TK2MSFTNGP10.phx.gbl...
    > Ah, are you moving your data out of the text files and migrating to a DB
    > now? Outstanding! What kind of troubles are you having, and if relevant,
    > what does the data in the text file look like? Also, what kind of DB are
    > you importing into?
    >
    > Ray at work
    >
    > "atse" <dunggaze@yahoo.com> wrote in message
    > news:P4_ib.334944$Lnr1.321256@news01.bloor.is.net. cable.rogers.com...
    > > Hi,
    > >
    > > I still have problem to import the text file delimited by tabs or commas
    > > into the database.
    > > I refer to [url]http://www.connectionstrings.com/[/url] for the connection, ODBC
    > > doesn't work and OLD DB works only for csv files. Any idea? Does anybody
    > has
    > > workable samples? Thanks a lot.
    > >
    > > ODBC
    > > Standard:
    > > "Driver={Microsoft Text Driver (*.txt;
    > > *.csv)};Dbq=c:\txtFilesFolder\;Extensions=asc,csv, tab,txt;"
    > >
    > > OLE DB
    > > Standard:
    > > "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\txtFilesFolder\;Extended
    > > Properties=""text;HDR=Yes;FMT=Delimited"""
    > >
    > > Atse
    > >
    > >
    >
    >










    atse Guest

  5. #4

    Default Re: import txt into database

    What is "thisfile.txt?" Is that the name of a table in an Access database,
    or is that your filename? What is your code?

    Ray at home

    "atse" <dunggaze@yahoo.com> wrote in message
    news:q20jb.336869$Lnr1.9807@news01.bloor.is.net.ca ble.rogers.com...
    >
    > When I try:
    > select * from thisfile.txt and then insert these records into a designated
    > table of the database.
    >
    > the error message is:
    >
    > Microsoft JET Database Engine error '80040e14'
    >
    > Syntax error in FROM clause.
    >
    > /insertfile.asp, line 46
    >
    > ' line 46 is
    > set rs = conn.execute("select * from thisfile.txt")
    >
    >

    Ray at Guest

  6. #5

    Default Re: import txt into database

    'thisfile.txt is a text file, and I am using MySQL but not Access

    'below is the code of what I am going to do with a text file. Please ignore
    the typing errors when I make something changed from the original codes. If
    the file is csv (thisfile.csv), it works fine.

    sConnection="driver={MySQL ODBC 3.51
    Driver};server=localhost;database=upload;uid=root; "
    set conn=server.CreateObject("ADODB.Connection")
    conn.open(sConnection)

    constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myPath &
    "\;Extended Properties=""text;HDRNo;FMT=Delimited"""
    set conn2=server.CreateObject("ADODB.Connection")
    conn2.open(constr)

    myPath="D:\uploadtemp\"
    file_name = "thisfile.txt"

    fileStr="select * from " & file_name

    set dRs=conn2.execute(fileStr)

    ' insert the recordset into the database.

    do until dRs.eof

    insertStr="insert into file (filename "

    for i = 1 to dRs.Fields.Count
    insertStr=insertStr &", f" & i
    next

    insertStr = insertStr &") "
    insertStr = insertStr & "values ('"&file_name&"'"

    for k = 1 to dRs.Fields.Count
    fieldata = dRs(k-1)

    insertStr = insertStr &", '" & fieldata & "'"
    next

    insertStr = insertStr &") "

    conn.Execute(insertStr)
    dRs.MoveNext
    loop

    dRs.close : set dRs = nothing
    conn.Close : set conn=nothing
    conn2.Close : set conn2 = nothing



    "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
    news:eel4VWskDHA.2732@TK2MSFTNGP11.phx.gbl...
    > What is "thisfile.txt?" Is that the name of a table in an Access
    database,
    > or is that your filename? What is your code?
    >
    > Ray at home
    >
    > "atse" <dunggaze@yahoo.com> wrote in message
    > news:q20jb.336869$Lnr1.9807@news01.bloor.is.net.ca ble.rogers.com...
    >
    > >
    > > When I try:
    > > select * from thisfile.txt and then insert these records into a
    designated
    > > table of the database.
    > >
    > > the error message is:
    > >
    > > Microsoft JET Database Engine error '80040e14'
    > >
    > > Syntax error in FROM clause.
    > >
    > > /insertfile.asp, line 46
    > >
    > > ' line 46 is
    > > set rs = conn.execute("select * from thisfile.txt")
    > >
    > >
    >
    >

    atse Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139