Data missing While importing Text file (.txt) to sql server 2008 using ASP
-
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,