找回密码
 加入
搜索
查看: 5161|回复: 8

[AU3基础] 如何从SQLITE数据库中读取数据并显示在ComboBox中(已解决)

  [复制链接]
发表于 2010-9-9 17:00:38 | 显示全部楼层 |阅读模式
本帖最后由 shenrenba 于 2010-9-9 17:13 编辑

RT, 帮我修改下代码  Msgbox显示的都对 就是控件中显示为空

-------------------------
用错函数了...


#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <ButtonConstants.au3>
#include <GuiComboBoxEx.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$sqlpath = @ScriptDir & "\ceshi.db"
$sqlname = "ceshi"
_SQLite_Startup()
Local $hQuery, $aRow
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 96, 48, 385, 209)
$Combo1 = _GUICtrlComboBox_Create($Form1, "", 160, 104, 249, 25, $CBS_DROPDOWN + $CBS_AUTOHSCROLL + $CBS_SIMPLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
xs()
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
Func xs()
        _SQLite_Open($sqlpath)
        _SQLite_Exec(-1, "CREATE TABLE " & $sqlname & " (a,b,c);")
        _SQLite_Exec(-1, "INSERT INTO " & $sqlname & " (a,b,c) VALUES ('c','2','World');")
        _SQLite_Exec(-1, "INSERT INTO " & $sqlname & " (a,b,c) VALUES ('b','3',' ');")
        _SQLite_Exec(-1, "INSERT INTO " & $sqlname & " (a,b,c) VALUES ('a','1','Hello');")
        _SQLite_Query(-1, "SELECT * FROM " & $sqlname & " ORDER BY a DESC;", $hQuery)
        While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
                MsgBox(0, "", $aRow[0])
                _GUICtrlComboBoxEx_BeginUpdate($Combo1)
                _GUICtrlComboBox_AddString($Combo1, $aRow[0])
                _GUICtrlComboBoxEx_EndUpdate($Combo1)
        WEnd
        _SQLite_Close()
EndFunc   ;==>xs
发表于 2010-9-9 17:43:25 | 显示全部楼层
回复 1# shenrenba
第16行增加_GUICtrlComboBoxEx_InitStorage ($Combo1, 1000, 5000)试试。

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-9-10 08:36:03 | 显示全部楼层
回复 2# 3mile


    你的方法不可行的  是函数错误


40行 _GUICtrlComboBox_AddString 不能用_GUICtrlComboBoxEX_AddString
发表于 2011-8-5 11:12:52 | 显示全部楼层
怎么做的,我也想知道
发表于 2011-9-2 16:48:10 | 显示全部楼层
此方髮學習中
发表于 2012-2-14 03:44:17 | 显示全部楼层
急需这方面资料
发表于 2012-2-14 07:09:02 | 显示全部楼层
本帖最后由 netegg 于 2012-2-14 07:31 编辑

[au3]#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <ButtonConstants.au3>
#include <GuiComboBoxEx.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$sqlpath = @ScriptDir & "\ceshi.db"
$sqlname = "ceshi"
_SQLite_Startup()
Local $hQuery, $aRow
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 96, 48, 385, 209)
$Combo1 = _GUICtrlComboBox_Create($Form1, "", 160, 104, 249, 25, $CBS_DROPDOWN + $CBS_AUTOHSCROLL + $CBS_SIMPLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
xs()
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
Func xs()
        _SQLite_Open($sqlpath)
        _SQLite_Exec(-1, "CREATE TABLE " & $sqlname & " (a,b,c);")
        _SQLite_Exec(-1, "INSERT INTO " & $sqlname & " (a,b,c) VALUES ('c','2','World');")
        _SQLite_Exec(-1, "INSERT INTO " & $sqlname & " (a,b,c) VALUES ('b','3',' ');")
        _SQLite_Exec(-1, "INSERT INTO " & $sqlname & " (a,b,c) VALUES ('a','1','Hello');")
        _SQLite_Query(-1, "SELECT * FROM " & $sqlname & " ORDER BY a DESC;", $hQuery)
        ;                _GUICtrlComboBoxEx_InitStorage($Combo1, 150, 300)
        _GUICtrlComboBoxEx_BeginUpdate($Combo1)
        While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
                ;                MsgBox(0, "", $aRow[0])
                _GUICtrlComboBox_AddString($Combo1, $aRow[0])
                ;                                ExitLoop
        WEnd
        _GUICtrlComboBoxEx_EndUpdate($Combo1)
        _SQLite_Close()
EndFunc   ;==>xs

[/au3]
发表于 2012-2-14 07:30:31 | 显示全部楼层
本帖最后由 netegg 于 2012-2-14 07:36 编辑

回复 2# 3mile

小数据量似乎不用对存储空间先进行初始化
发表于 2012-2-14 07:38:01 | 显示全部楼层
本帖最后由 netegg 于 2012-2-14 07:53 编辑

回复 3# shenrenba

函数是没错的,ex本身就可以操作非ex的combo控件,只是可选参数多了不少
另外再说一句,编程别太死,combo(ex)不但能操作自己建立的,外部控件都行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-17 17:31 , Processed in 0.083047 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表