locked
Csv Connection String RRS feed

  • Question

  • User637234440 posted

    Oledb Connection String for csv file and select statement for csv file

    Monday, September 26, 2011 8:59 AM

Answers

  • User826222609 posted
    
    oConn.Open _
    "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
    "Dbq=c:\somepath\;" & _
    "Extensions=asc,csv,tab,txt"
    Then specify the filename in the SQL statement:
    
    oRs.Open "Select * From customer.csv", _
    oConn, adOpenStatic, adLockReadOnly, adCmdText
    Note: If you are using a Tab delimited file, then make sure you create a schema.ini file, and include the "Format=TabDelimited" option. 
    
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 26, 2011 9:38 AM

All replies

  • User2010474417 posted

    Hi,

    Try like this

    insert into table_name(fileld1,fileld2,fileld3)
    select  column1,column2,column3
    from OPENROWSET
    ('Microsoft.Jet.OLEDB.4.0','Text;Database=C:\Documents and Settings\Administrator\Desktop;HDR=YES',
     'SELECT * FROM [FileName.csv]')

    Monday, September 26, 2011 9:13 AM
  • User826222609 posted
    
    oConn.Open _
    "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
    "Dbq=c:\somepath\;" & _
    "Extensions=asc,csv,tab,txt"
    Then specify the filename in the SQL statement:
    
    oRs.Open "Select * From customer.csv", _
    oConn, adOpenStatic, adLockReadOnly, adCmdText
    Note: If you are using a Tab delimited file, then make sure you create a schema.ini file, and include the "Format=TabDelimited" option. 
    
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 26, 2011 9:38 AM