Truncation problem during CSV reading

  • Hi everybody,

    I am facing a problem while inserting data from CSV file to SQL Table. Same thing I am doing From Excel file it is working fine.

    -----------------------

    My CSV file format is like this:

    FirstName,LastName,Email,IP

    testFname1,testLname1,test1@test.com,111.111.111.111

    testFname2,testLname2,test2@test.com,222.222.222.222

    Now when I am reading from this CSV IP reads as

    111.1111

    222.2222

    I think CSV is taking this as float.

    I tried to convert,cast etc. but it's not working and the code I am using to read is as below:

    ---------------Start Code

    Dim strCSV as string

    Dim upRS as Object

    strCSV = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="+mypath+";Extensions=asc,csv,tab,txt;Persist Security Info=False;"

    upRS = Server.CreateObject("ADODB.Recordset")

    upRS.ActiveConnection = strCSV

    upRS.Source = "select FirstName,LastName,Email,IP from " & request("F")

    upRS.CursorType = 0

    upRS.CursorLocation = 2

    upRS.LockType = 3

    upRS.Open()

    -----------------End Code

    I hope i'll get a good and quick solution for this problem.

    Thanks to all

    Regards,

    Haresh Vachhani.

  • This was removed by the editor as SPAM

  • Have you tried CSTR()?

    CSV has it as just text, the driver may see it differently, but from a text file, I'm not sure CAST or CONVERT work. I'd deal with it in VB.

  • Thanks Steve

    I tried with CSTR() also, but it's not giving me my desired result.

    Thanks again

    Haresh Vachhani

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply