How to output MySQL data to a file

上一篇 / 下一篇  2006-12-22 02:35:33 / 个人分类:QTP

This is the way how to output your MySQL result to a file:

 ********************************************************************************

 Set Conn = CreateObject("ADODB.Connection" )

str="DRIVER={MySQL ODBC 3.51 Driver};SERVER=webdev;DATABASE=intranet;user id=root ; password=xxxx"

Conn.open str

Set Rs = CreateObject ("ADODB.Recordset" )

sql = "select * from `user` limit 5;"

Rs.open sql,conn,1,3

 '**********  Define variable  *******

Dim fso, myfile,i

Set fso=CreateObject("scrīpting.FileSystemObject")

 '**********  Point TXT file name  *******

Set myfile=fso.openTextFile("C:\result.txt",8,false)

 '**********  wtite to TXT file  *******

While Not Rs.eof

     for i=1 to 6

            myfile.writeline Rs(i)

      next

     myfile.writeline " "

     Rs.movenext

wend

 '**********  Close file  *******

myfile.close

 '**********  Close result  *******

Rs.close

 Set Rs = Nothing

Conn.close

Set Conn = Nothing


TAG: QTP

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-08  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 3853
  • 日志数: 7
  • 建立时间: 2006-12-19
  • 更新时间: 2008-10-17

RSS订阅

Open Toolbar