DELPHI当前提供程序不支持从单一执行返回多个记录集
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DELPHI当前提供程序不支持从单一执行返回多个记录集相关的知识,希望对你有一定的参考价值。
ADOQuery4.Close;
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('insert into 开设的房台 (编号,房间名称,餐饮部门,服务费,服务员,开房时间)');
ADOQuery4.SQL.Add(' values (:BH,:FJMC,:CYBM,:FWF,:FWY,:KFSJ)');
ADOQuery4.Parameters.ParamByName('BH').Value:=DBText1.Caption;
ADOQuery4.Parameters.ParamByName('FJMC').Value:=DBText2.Caption;
ADOQuery4.Parameters.ParamByName('CYBM').Value:=DBText4.Caption;
ADOQuery4.Parameters.ParamByName('FWF').Value:=DBText5.Caption;
ADOQuery4.Parameters.ParamByName('FWY').Value:=LJ;
//LJ是lJ:=LJ+ListBox1.Items.Strings[ListBox1.ItemIndex]
//listbox里面的值是用另一个adoquwey5查询字段循环出来的;
ADOQuery4.Parameters.ParamByName('KFSJ').Value:=Datetimetostr(now());
ADOQuery4.ExecSQL;
执行后 表的确有插入记录 但我的DBGrid却显示空白了 连原来的都没了 我去问别人跟我说后面加:
adoquery4.Active:=true; 加了就出错了
例如SQL为: select * from a select * from b
返回了两个数据集,就会报上面的错误
那你可以动态生成一个ADOQuery 来替换ADOQuery4.因为dbgrid只是ADOQuery4的表现控件,你用ADOQuery4来插入数据了,就没有数据集了。
ADOQuery:= TADOQuery.Create(nil);
try
//执行你的代码
finally
ADOQuery.Free;
ADOQuery4.refresh; //最后别忘了刷新ADOQuery4
end; 参考技术A 一般,用于写数据记录的Query,跟用于显示数据到DBGrid中的Query,两个Query是独立的。
当用写记录的Query执行完Insert操作后,用于显示数据的Query就执行一下Refresh过程,这样就能刷新出新的数据。 参考技术B 这是ADO的缺陷,当使用oracle的with语句时就会发生此错误
bash脚本返回值应用
bash脚本返回值应用
应该说bash脚本对于linux系统来说具有举足轻重的意义。
这里不做展开,也不做bash脚本介绍。更多的是做一个例子,应用了bash脚本的以下特性:
- 输入参数
- 函数定义
- 调用可执行命令
- 脚本递归
- 条件判断
脚本具有以下功能:
- 支持可执行文件判断
- 支持单一文件可执行判断(echo $?查询)
- 支持多个文件可执行判断 (直接打印输出)
执行效果:
$ ./bash_script.sh bash_script.sh a.out test.c ttt.txt test.txt
x:./bash_script.sh bash_script.sh
x:./bash_script.sh a.out
x:./bash_script.sh test.c
n:./bash_script.sh ttt.txt
n:./bash_script.sh test.txt
脚本代码:
#!/bin/sh
# HELP
# param: file name
# description: check file existed and exectuable, return 1 or 0 (for NOT existed or unexectuable file)
# x: file existed and exectuable
# n: normal file
# e.g.
# $ ./bash_script.sh test.txt a.out
# n:./bash_script.sh test.txt
# x:./bash_script.sh a.out
#
PRINT ()
if [ $1 = 1 ]; then
echo "x:$2 $3"
else
echo "n:$2 $3"
fi
HELP ()
echo $0
echo "param: file name"
echo "description: check file existed and exectuable, return 1 or 0 (for NOT existed or unexectuable file)"
echo "x: file existed and exectuable"
echo "n: normal file"
echo "e.g. "
echo "$ ./bash_script.sh test.txt a.out"
echo "n:./bash_script.sh test.txt"
echo "x:./bash_script.sh a.out"
EXEC_FILE_NAME=$0
case $# in
0) HELP
#EXEC_COMMAND="$EXEC_FILE_NAME $EXEC_FILE_NAME";
#bash $EXEC_COMMAND
#ERR=$?
#PRINT $ERR $EXEC_FILE_NAME $EXEC_FILE_NAME
break;;
1) if [ -x "$1" ]; then
exit 1
else
exit 0
fi
break;;
*) EXEC_COMMAND="$EXEC_FILE_NAME $1";
bash $EXEC_COMMAND
ERR=$?
PRINT $ERR $EXEC_FILE_NAME $1
shift
EXEC_COMMAND="$0 $@"
bash $EXEC_COMMAND
ERR=$?
if [ $# = 1 ]; then
PRINT $ERR $0 $@
fi
esac


以上是关于DELPHI当前提供程序不支持从单一执行返回多个记录集的主要内容,如果未能解决你的问题,请参考以下文章