public class ZqHotel1 {
public void hellosql(String yhm,String hotelname,String roomstyle,String roomprice,String hoteldate,String roomnumber) {
try{ClassforName("commicrosoftjdbcsqlserverSQLServerDriver")newInstance();}
catch(Exception e){}
String user="sa";
String password="12161216";
Connection con=DriverManagergetConnection("jdbc:microsoft:sqlserver://127001:1433;DatabaseName=zq",user,password);
Statement stmt = concreateStatement();
stmtexecuteUpdate("insert into hotel(yhm,hotelname,roomstyle,roomprice,hoteldate,roomnumber) values('"+yhm+"','"+hotelname+"','"+roomstyle+"','"+roomprice+"','"+hoteldate+"','"+roomnumber+"')");
stmtclose();
conclose();
}
}前面二行是定义字符串,
然后,获得录入的用户和口令。
在然后,按录入的用户名查询数据,判断用户是否存在,如果不存在,返回
在然后,按录入的用户名查询出对应的口,判断查询出来口令和录入口令是否一致。如果不一致,返回。
在然后,gs_userid = ls_userid 使用户ls_userid存放在全局变量中,方便以后使用。
在然后,post close(parent) 关掉登陆窗口
在然后,open(w_main) 打开主界面在插入之后,即insert 语句之后,使用sqlcasqlcode的值来判断。如果是0,表示成功。
if sqlcasqlocde = 0 then //语句成功
commit; //提交,数据库才会接收插入值
messagebox("提示","插入成功!")
else
rollback;
messagebox("提示","插入失败!")
end ifnew 窗口下的,custom class 和 standard class 就是非可视化对象 可视化通俗点说就是窗口内看的到的,比如,按钮阿文本 那么非可视化就是看不到,比如几个函数的集合
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)