//添加数居
string sex
integer id=integer(sle_id.text)
string name=sle_name.text
if rb_man.checked=true then
sex='男'
end if
if rb_woman.checked=true then
sex='女'
end if
integer card=integer(sle_card.text);
integer num=integer( sle_num.text);
string position=ddlb_position.text;
string username=sle_loginname.text;
date injob=date( dp_injob.text);
string pass=sle_password.text;
integer dep=integer(ddlb_dep.text);
string email=sle_email.text;
string createname=loginname;
integer phone=integer( sle_phone.text);
integer state=integer(sle_state.text);
integer p_type=integer(ddlb_type.text);
date outjob= date(dp_outjob.text);
INSERT INTO "person"
( "per_id",
"per_name",
"per_sex",
"per_card",
"per_number",
"per_position",
"per_username",
"per_injob",
"per_password",
"per_department",
"per_eamil",
"per_createname",
"per_phone",
"per_state",
"per_type",
"per_outjob" )
VALUES ( :id,
:name,
:sex,
:card,
:num,
:position,
:username,
:injob,
:pass,
:dep,
:email,
:createname,
:phone,
:state,
:p_type,
:outjob ) ;
commit using sqlca;
错误提示是这个 invalid variable declaration initialization 到底是哪错了 很不解 谢谢大家
------解决方案--------------------
//帮你改进了代码,测试没有问题,都可以插入数据
integer id ,dep, phone,state,p_type,num
string card,name ,sex,position,username,pass,email,createname
date outjob,injob
card='test'
name='test'
position='test'
username='test'
pass='test'
email='test'
createname='test'
id =0
dep=0
phone=0
state=0
p_type=0
num=0
outjob=date(today())
injob=date(today())
if rb_man.checked then
sex='男'
else
sex='女'
end if
//插入参数与字段一个不少,一一对应
insert into person VALUES ( :id,
:name,
:sex,
:card,
:num,
:position,
:username,
:injob,
:pass,
:dep,
:email,
:createname,
:phone,
:state,
:p_type,
:outjob ) ;
commit;
------解决方案--------------------
哪一行报错?
------解决方案--------------------
1 loginname 变量是否声明过?
2 声明变量,赋值最好不要安你做那种用下边这种
sting ls_name,ls_sex,ls_position
integer li_id
li_id = integer(sle_id.text)
ls_name = sle_1.text
ls_position = ddlb_position.text;
3 单选按钮判断是否选中,可以直接用
if rb_man.checked then
//
end if
4 对数据库操作过后,最好判断sqlca.sqlcode的值,来检查跟数据库交互是否有错误发生,如果没有错误发生commit,否则rollback.
------解决方案--------------------