- 论坛徽章:
- 0
|
我在用application buider编用户界面,我现在设计了一个登陆界面。要求用在数据库中的人员编号与口令登录。我用的数据库是oracle,编程语言是c。存储数据的数据库是user_table。ticket.pc文件里面的原函数是:
char *get_password(int user_num1)
EXEC SQL BEGIN DECALRE SECTION;
char user_password_out[8];
short user_password_out_ind; /*指示符变量 */
char user_name_host[8];
EXEC SQL END DECALRE SECTION;
EXEC SQL declare password_cursor for
select user_name,user_password from user_table
where user_num= :user_num1;
EXEC SQL open password_cursor;
EXEC SQL fetch password_cursor into :user_name_host,:user_password_out:user_password_out_ind; /* 如果用户存在就返回用户口令 */
if (user_password_out_ind==0)
return (user_password_out);
else return(NULL);
EXEC SQL close password_cursor;
}
在主函数在application builder 的stubs.c里面:
char *user_num_text=(char *)NULL;
char *user_password_text=(char *)NULL;
int temp_num,temp_password;
char text[8];
/*从界面的控件上面取数*/
temp_num=XmTextFieldGetString(dtb_das1_mainwindow.user_num)
temp_password=XmTextFieldGetString(dtb_das1_mainwindow.user_password)
spritf(&user_password_text,"%d",temp_password);
memcpy(text,get_password(temp_num), ;
printf("text0=%s",text);
/*用户不存在 */
if (text ==NULL)
{ printf("not find the user\n" ;
printf("text1=%s\n",text)
}
/*密码错误*/
if(text != user_password_text)
{
printf("password wrong\n" ;
printf("text2=%s\n",text);
}
/*通过验证*/
if(text==user_password_text)
{
printf("success\n" ;
printf("text3=%s\n",text);
}
这样写text的返回值可以吗》? |
|