用pb写的第一个数据窗口

用PowerBuilder写了一个数据窗口,数据窗口写好了以后运行报错

DataWindow Error

Database transaction information not available

Call SetTrans or SetTransObject function

最后检查发现程序没有写错,是我的运行方式不对,应该从主程序开始运行。

下面的程序是在网上找到的判断是否连接的语句

if sqlca.dbhandle()>0 then

messagebox('test connection','连接着')

else

messagebox('test connection','没连接')

end if

连接通了以后运行时发现不能添加数据,报违反主键的唯一性约束的错误,

SQLSTATE = 23000

[Sybase][ODBC Driver][Adaptive Server Anywhere]Integrity constraint violation: Column 'sys_num' in table 'student' cannot be NULL

No changes made to database.

INSERT INTO "student" ( "sys_num", "s_id", "s_name", "tel" ) VALUES ( ?, ?, ?, ? )

这个是主键的问题,直接把主键删除就可以了,删除之后在从新添加主键也可以正常使用。

posted @ 2018-08-24 14:02  水兮云间  阅读(528)  评论(0编辑  收藏  举报