一行一行的读,
每一行处理一下,根据分隔符分开,然后放到datatable的一行里
不是很复杂

解决方案 »

  1.   

    每行每个字段都是用tab键隔开的
      

  2.   

    能帮忙给一个例子吗,谢谢,我自己也试试,我还想有没有象ado直接读这个文件的办法
      

  3.   

    BULK INSERT yourtable FROM 'E:\A.TXT'A.TXT
    ========================
    12      010101 1  1
    13            010101        2         1
      

  4.   

    take a look athttp://www.aspalliance.com/ericm/articles/textdb.asp
      

  5.   

    用这个方法得出的结果是每行作为一条记录了,我需要把每行的分成各个字段来存到datatable里,请问还有没有办法呢
      

  6.   

    ODBC Driver for Text 
    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. For more information, see:  Text File Driver Programming ConsiderationsTo view Microsoft KB articles related to Microsoft Text Driver, click here 
      

  7.   

    ODBC Driver for Text 
    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. For more information, see:  Text File Driver Programming ConsiderationsYou can also open a Text file using the JET OLE DB Provider oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
           "Data Source=c:\somepath\;" & _ 
           "Extended Properties=""text;HDR=Yes;FMT=Delimited"""
    'Then open a recordset based on a select on the actual fileoRs.Open "Select * From MyTextFile.txt", oConn, _
             adOpenStatic, adLockReadOnly, adCmdText 
      

  8.   

    http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q262/5/37.ASP&NoWebContent=1
      

  9.   

    oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
           "Data Source=c:\somepath\;" & _ 
           "Extended Properties=""text;HDR=Yes;FMT=Delimited"""
    'Then open a recordset based on a select on the actual fileoRs.Open "Select * From MyTextFile.txt", oConn, _
             adOpenStatic, adLockReadOnly, adCmdText 读出的记录是文本中第一行做表头,其余的行做记录集,请问怎样把文本中用tab键分开的字符串作为一个字段读出来,谢谢
      

  10.   

    一行一行读出来,然后用string.split分割,在一项一项邪道你的table里面去
      

  11.   

    一行一行读出来,然后用string.split分割,在一项一项邪道你的table里面去.
    这样当然是好,但是感觉好没有效率和好风格
      

  12.   

    怎么现在大家都不想讨论下去了吗,我一行一行读出来解决了,但我还是想通过ado.net来实现他