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
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
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键分开的字符串作为一个字段读出来,谢谢
========================
12 010101 1 1
13 010101 2 1
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
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
"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键分开的字符串作为一个字段读出来,谢谢
这样当然是好,但是感觉好没有效率和好风格