先用open语句建立新文件,再用print语句逐行写入。

解决方案 »

  1.   

    dim myconn as adodb.connection
    dim myrs as adodb.recordset
    dim i as integer,j as integer
    dim strline as string
    ...    'here to open the connection and recordset fit your filter
    open myfile for output as #1
    for i=0 to myrs.recordcount-1
       strline=myrs.fields(0).vlaue
       for j=1 to myrs.fields.count-1
           strline=strline &"," &myrs.fields(j).value
       next j
       print #1,strline
    next i
    close #1
    ...'here to release recordset and connection 
      

  2.   

    楼上的太麻烦,look 
    SELECT * INTO [text;database=c:\].导出表名.txt  FROM 表
      

  3.   

    recordset有getstring的函数可以直接把记录转化为字符串
    GetString 方法 (ADO Recordset)
             将 Recordset 作为字符串返回。语法Set Variant = recordset.GetString(StringFormat, NumRows, ColumnDelimiter, RowDelimiter, NullExpr)返回值将 Recordset 以值为字符串的变体型 (BSTR) 返回。参数StringFormat    指定 Recordset 应转换为下列格式。常量 说明 
    adClipString 行由 RowDelimiter 分界,列由 ColumnDelimiter 分界,NULL 值由 NullExpr 分界。这三个参数只有在与 adClipString 一起使用时才有效。 
    NumRows    可选。记录集要转换的行数。如果没有指定 NumRows,或者它大于记录集的总行数,则记录集的所有行都要转换。ColumnDelimiter    可选。如果指定则为列之间的分界符,否则为 TAB 字符。RowDelimiter    可选。如果指定则为行之间的分界符,否则为 CARRIAGE RETURN 字符。NullExpr    可选。如果指定则为代替 NULL 值的表达式,否则为空串。 说明保存到字符串的数据为行数据而非纲要数据,因此不能使用该字符串重新打开记录集。该方法等价于 RDO GetClipString 方法。