Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Data missing While importing Text file (.txt) to sql server 2008 using ASP

Data missing While importing Text file (.txt) to sql server 2008 using ASP

Scheduled Pinned Locked Moved Web Development
helpdatabasesql-serversysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    priyaahh
    wrote on last edited by
    #1

    Hi Friends, I am using asp to import data from .txt (tab delimited) to SQL Server 2008. I have found some problem with my code now. ie., some data is not getting read from textfile hence its not inserted into table. But still data present in .txt. I am not sure what will be the cause for this issue. Below is my code.

    cnnText.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & \_
    "Data Source=D:\\Sangeetha\\commodul\\ACDT\\UploadFile\\;" & \_
    "Extended Properties=""text;HDR=YES;IMEX=0;FMT=TabDelimited"""
    
    ' Load ADO Recordset with Text Data
    Set rstText = Server.CreateObject("ADODB.Recordset")
    'rstText.Open "Select \* from \[" & file\_name & "\]", cnnText,2,3,adcmdText
    rstText.Open "Select \* from \[" & file\_name & "\]", cnnText
    
        Set rstAccess = Server.CreateObject("ADODB.Recordset")
        rstAccess.Open "select \* from CReport", connection, 2,3
    
         Do Until rstText.EOF
            With rstAccess
              'if not(isnull(rstText.Fields("reporting\_date"))) then       
                 .AddNew
                  .Fields("credit\_group").Value =  rstText.Fields.Item("credit\_group")
                  .Fields("credit\_group\_aig\_number").Value =  rstText.Fields.Item("credit\_group\_aig\_number")
                  .Fields("credit\_group\_gdr\_id").Value =  rstText.Fields.Item("credit\_group\_gdr\_id")'new
                  .Fields("credit\_group\_domicile\_code").Value =  rstText.Fields.Item("credit\_group\_domicile\_code")
                  .Fields("credit\_group\_domicile").Value =  rstText.Fields.Item("credit\_group\_domicile")
    
                  rstText.MoveNext
              'else
                'rstText.MoveNext
              'end if
              End With
        Loop
          rstAccess.UpdateBatch
    

    I have tried by keeping IMEX as 1. Only for some of the columns this problem is happening. Eg:

    credit_group_aig_number

    is a column where for some row records is getting read and for some row this col value its not at all reading from connector. I tried with Response.Write, no value is printing even that row is having value in text file. I have noticed that column has input of 9 digit id which starts with number as well as alphabet. Only where its start with alphabet this is problem. Kindly help. Thanks,

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups