|
4#
楼主 |
发表于 2009-2-24 13:45:47
|
只看该作者
可以了,现在用的下面的代码:
#
# 连接数据库-查询-导出文件
#
if(db_connect ("query1","DSN=test_sql;Description=数据库测试;UID=saWD=11;APP=WinRunner;WSID=WWW-B82C2FBDDB9;DATABASE=htf_test",30)==E_OK)
{report_msg("数据库连接成功");
MSG = time_str(get_time());
Result = "e:\\13.txt";
file_open(Result,2);
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据库连接成功 \r\n",MSG,i);#write data in txt file
}
else
{report_msg("数据库连接失败");
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据库连接失败 \r\n",MSG,i);#write data in txt file
}
#######################################################
if(db_execute_query ("query1","SELECT * FROM vip_new_lw",num)==E_OK)
{report_msg("数据查询成功");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据查询成功 \r\n",MSG,i);#write data in txt file
}
else
{report_msg("数据查询失败");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据查询失败 \r\n",MSG,i);#write data in txt file
}
if(db_write_records ("query1","E:\\11.txt",TRUE,5)==E_OK)
{report_msg("数据导出成功");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据导出成功 \r\n",MSG,i);#write data in txt file
}
else
{report_msg("数据导出失败");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据导出失败 \r\n",MSG,i);#write data in txt file
}
# 比较文件 E:\\11.txt和E:\\12.txt
#
if(file_compare("E:\\11.txt","E:\\12.txt","save")==E_OK)
{report_msg("数据相同");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据相同 \r\n",MSG,i);#write data in txt file
file_printf(Result,"%d-------------------------------------------------------------\r\n",MSG,i);
file_close(Result);
}
else
{report_msg("数据不同");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据不同 \r\n",MSG,i);#write data in txt file
file_printf(Result,"%d-------------------------------------------------------------\r\n",i);
file_close(Result);
}
导出效果为:
Tue Feb 24 12:24:25 2009 : 0 数据库连接成功
Tue Feb 24 12:24:25 2009 : 0 数据查询成功
Tue Feb 24 12:24:25 2009 : 0 数据导出成功
Tue Feb 24 12:24:25 2009 : 0 数据不同
0-------------------------------------------------------------
Tue Feb 24 12:24:37 2009 : 0 数据库连接成功
Tue Feb 24 12:24:37 2009 : 0 数据查询成功
Tue Feb 24 12:24:37 2009 : 0 数据导出成功
Tue Feb 24 12:24:37 2009 : 0 数据不同
0-------------------------------------------------------------
Tue Feb 24 12:25:14 2009 : 0 数据库连接成功
Tue Feb 24 12:25:14 2009 : 0 数据查询成功
Tue Feb 24 12:25:14 2009 : 0 数据导出成功
Tue Feb 24 12:25:14 2009 : 0 数据相同
0------------------------------------------------------------- |
|