lr_db_connect | 连接数据库 |
lr_db_disconnect | 断开数据库的连接 |
lr_db_executeSQLStatement | 执行SQL语句 |
lr_db_dataset_action | 对数据库执行操作 |
lr_db_getValue | 从数据集中检索值 |
问题:sql如何实现
支持四中数据库连接模式
sql
oledb
odbc
oracle
1、使用web services协议
Action()
{
int mun=0;
int i;
//连接
lr_db_connect("StepName=Connect to DB",
"ConnectionName=db1",
"ConnectionString=Provider=OraOLEDB.Oracle.1;Data Source=QFTEST;Password=SHENZHENJM1222;User ID=SHENZHENJM1222",
"ConnectionType=OLEDB",
LAST);
//执行
mun=lr_db_executeSQLStatement("StepName=PerformQuery",
"ConnectionName=db1",
"SQLStatement=select * from t_test_user ",
"DatasetName=select",
LAST);
lr_output_message("The query returned %d rows.", mun);
//打印结果
/*
lr_db_dataset_action("StepName=PrintDataset",
"DatasetName=select",
"Action=PRINT",
LAST );*/
//循环读取并输出sql查询得到的值,这里的判断根据需要适当进行修改
while(i<mun)
{
lr_db_getvalue("StepName=GetValue",
"DatasetName=select",
"Column=fcell", //Column 为要取得列的值,
"Row=next",
"OutParam=MyOutputParam",
LAST);
lr_output_message("The value is: %s", lr_eval_string("{MyOutputParam}") );
i=i+1;
}
lr_db_disconnect("StepName=Disconnect",
"ConnectionName=db1",
LAST);
return 0;
}