dropdownlistbox连接数据库

sephirothzjf 2013-03-08 07:01:39
string ls_temp
declare readdate dynamic cursor for sqlsa;
string ls_sql="select tuzhiname from tuzhiinfo where userno=:sdf"
prepare sqlsa from :ls_sql;
open dynamic readdate;
do while sqlca.sqlcode=0
fetch readdate into:ls_temp;
if sqlca.sqlcode=0 then
ddlb_1.additem(ls_temp)
end if
loop
ddlb_1.SelectItem(1)
close readdate;

求助大家,以上代码连接了ddlb,但是“select tuzhiname from tuzhiinfo where userno=:sdf”
语句里的where条件里的":sdf"要怎样传进去。
...全文
242 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sephirothzjf 2013-04-29
  • 打赏
  • 举报
回复
自己解决了,呵呵,谢谢大家!
WorldMobile 2013-04-17
  • 打赏
  • 举报
回复
用以上的代码来试试吧
WorldMobile 2013-04-17
  • 打赏
  • 举报
回复
string ls_sdf //里面存你的参数 ls_sdf = "0001" string ls_temp declare readdate dynamic cursor for sqlsa; string ls_sql="select tuzhiname from tuzhiinfo where userno='" + ls_sdf + "'" prepare sqlsa from :ls_sql; open dynamic readdate; do while sqlca.sqlcode=0 fetch readdate into:ls_temp; if sqlca.sqlcode=0 then ddlb_1.additem(ls_temp) end if loop ddlb_1.SelectItem(1) close readdate;
sephirothzjf 2013-03-11
  • 打赏
  • 举报
回复
楼上的高手,好相不对,我的sdf是一个编号,有可能是"1001"也有可能是"1002"
softvery 2013-03-10
  • 打赏
  • 举报
回复
嗯,是的,如果你的变量值是sdf直接换成这个就行了,也就是组合成一个字符串。 string ls_sql="select tuzhiname from tuzhiinfo where userno='"+sdf +"'"
sephirothzjf 2013-03-09
  • 打赏
  • 举报
回复
感谢楼上,但是不好意思,我是新手,'"+ls_sdf +"'"这个值是怎么传进来的呢?是不是把我原来的变量sdf换成这个'"+ls_sdf +"'就可以用了?
softvery 2013-03-09
  • 打赏
  • 举报
回复
使用动态语法4(Dynamic SQL Format 4 SQL statement) string Sqlstatement, sValue Sqlstatement = "SELECT emp_fname, emp_lname " & + "FROM employee WHERE state = ?" PREPARE SQLSA FROM :Sqlstatement ; DESCRIBE SQLSA INTO SQLDA ; // If the DESCRIBE is successful, the input // descriptor array will contain one input // descriptor that you must fill prior to the OPEN DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ; SetDynamicParm(SQLDA, 1, "MA") OPEN DYNAMIC my_cursor USING DESCRIPTOR SQLDA ; FETCH my_cursor USING DESCRIPTOR SQLDA ; 。。。。。。。。 但是这样的语句可读性差一些,不如使用 string ls_sql="select tuzhiname from tuzhiinfo where userno='"+ls_sdf +"'" 组合好直接使用直接一些。 另:敬请关注TOPANY PB.NET框架

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧