回 帖 发 新 帖 刷新版面

主题:下拉列表框如何显示表中的纪录??

下拉列表框如何显示表中的纪录??未出现错误提示,就是列表框无内容,请高手解决,多谢!!!

下面是ddlb_1的constructor的代码:
Datastore ldt_1

ldt_1 = Create Datastore

ldt_1.Dataobject="d_xibuliebiao"//d_xibuliebiao是数据窗口对象

ldt_1.SetTransObject(SQLCA)
ldt_1.Retrieve()

Long ll_row,ll_total

ll_Total = ldt_1.RowCount()

If ll_Total<=0 Then 
    Destroy(ldt_1)
    Return
End If

For ll_Row = 1 To ll_Total
    
    This.AddItem(ldt_1.GetItemString(ll_row,1))
    
End For

Destroy(ldt_1)

回复列表 (共6个回复)

沙发

For ll_Row = 1 To ll_Total
    
    This.AddItem(ldt_1.GetItemString(ll_row,1))
    
End For

有End For 的语法吗?

板凳


我觉得有点问题,因为是在ddlb_1的constructor
里面编写的。


// Profile 
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=??????'"
connect using sqlca;

应该加上这一段吧?

3 楼


兄弟,请你学着自己调试一下,再不然的话,多用几个messagebox也可以啊,看你的数据库库有没有连成功啊!!!
  请在constructor事件里写东西要注意,它是先加完窗口的控件的东西然后才执行窗口的open()事件...........

SQLCA.DBMS = "MSS Microsoft SQL Server 6.x"
SQLCA.Database = "cport"
SQLCA.LogPass ='sql'
SQLCA.ServerName = "."
SQLCA.LogId = "sa"

SQLCA.AutoCommit = False
SQLCA.DBParm = ""
connect using sqlca;
if sqlca.sqlcode = 0 then
    commit using sqlca;
else 
    messagebox('提示','连接数据库失败!')
    rollback;
end if



Datastore ldt_1

ldt_1 = Create Datastore

ldt_1.Dataobject="ddw_cport_list"//d_xibuliebiao是数据窗口对象

ldt_1.SetTransObject(SQLCA)
ldt_1.Retrieve()

Long ll_row,ll_total

ll_Total = ldt_1.RowCount()


messagebox('',string(ll_total))
If ll_Total<=0 Then 
    Destroy(ldt_1)
    Return
End If

For ll_Row = 1 To ll_Total
    
    This.AddItem(ldt_1.GetItemString(ll_row,'code'))
    
End For

Destroy(ldt_1)

4 楼

楼上的真搞笑?
for .............
   ..........

end for ???????

5 楼

SQLCA.DBMS = "MSS Microsoft SQL Server 6.x"
SQLCA.Database = "cport"
SQLCA.LogPass ='sql'
SQLCA.ServerName = "."
SQLCA.LogId = "sa"

SQLCA.AutoCommit = False
SQLCA.DBParm = ""
connect using sqlca;
if sqlca.sqlcode = 0 then
    commit using sqlca;
else 
    messagebox('提示','连接数据库失败!')
    rollback;
end if



Datastore ldt_1

ldt_1 = Create Datastore

ldt_1.Dataobject="ddw_cport_list"//d_xibuliebiao是数据窗口对象

ldt_1.SetTransObject(SQLCA)
ldt_1.Retrieve()

Long ll_row,ll_total

ll_Total = ldt_1.RowCount()


messagebox('',string(ll_total))
If ll_Total<=0 Then 
    Destroy(ldt_1)
    Return
End If

For ll_Row = 1 To ll_Total
    
    This.AddItem(ldt_1.GetItemString(ll_row,'code'))
    
Next

Destroy(ldt_1)

6 楼

楼上正解

我来回复

您尚未登录,请登录后再回复。点此登录或注册