找回密码
 加入
搜索
查看: 8341|回复: 18

[GUI管理] 已经解决 帮忙看看sqlite读取数据到 listview

 火.. [复制链接]
发表于 2012-4-22 08:17:07 | 显示全部楼层 |阅读模式
本帖最后由 xin266 于 2012-4-24 10:30 编辑
_SQLite_Open($SQLite_Data_Path)
        _SQLite_Query(-1, "SELECT * FROM TestTable ORDER BY Chanpin DESC;", $hQuery)
        
        While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
                
                GUICtrlCreateListViewItem($aRow[0] & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)
                
        WEnd
        _SQLite_Close()
已经解决  前面少了一句  _SQLite_Startup()
SQLite_Open($SQLite_Data_Path)
        _SQLite_Query(-1, "SELECT * FROM TestTable;", $hQuery)

        While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
                GUICtrlCreateListViewItem($aRow[0] & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)

        WEnd
        _SQLite_Close()
发表于 2012-4-22 09:09:07 | 显示全部楼层
发完整的代码和数据库上来!
 楼主| 发表于 2012-4-22 09:12:04 | 显示全部楼层
回复 2# hzxymkb
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include<date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Global $Msg, $hQuery, $aRow
$SQLite_Data_Path = "360.db"
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=C:\Users\changxin\Desktop\study\京东价格\Form1.kxf
$Form1 = GUICreate("京东历史价格工具", 895, 438, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$ListView1 = GUICtrlCreateListView("编号|价格|产品|日期", 0, 0, 745, 321)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 550)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 90)
$Label1 = GUICtrlCreateLabel("产品网址", 16, 344, 52, 17)
$Input1 = GUICtrlCreateInput("", 72, 344, 473, 31)
$Button1 = GUICtrlCreateButton("确定", 592, 344, 97, 49)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
While 1
        
        Sleep(100)
WEnd


Func Button1Click()

        $now = _Now()
        $url = GUICtrlRead($Input1)
        $oHTTP = ObjCreate("microsoft.xmlhttp")
        $oHTTP.open("get", $url, False)
        $oHTTP.send()
        $source2 = $oHTTP.responsetext

        $price = StringRegExp($source2, "我在@京东商城 发现了一个非常不错的商品:(.+),京东价:¥(\d+\.\d+)", 3)
        _SQLite_Startup()
        _SQLite_Open($SQLite_Data_Path)
        _SQLite_Exec(-1, "Insert into TestTable (Chanpin) values ('" & $price[0] & "');")


        _SQLite_Exec(-1, "UPDATE TestTable SET Jiage = '" & $price[1] & "' WHERE Chanpin = '" & $price[0] & "';")

        _SQLite_Exec(-1, "UPDATE TestTable SET Shijian = '" & $now & "' WHERE Chanpin = '" & $price[0] & "';")

        _SQLite_Close()

EndFunc   ;==>Button1Click
Func Form1Close()
        _SQLite_Open($SQLite_Data_Path)
        _SQLite_Query(-1, "SELECT * FROM TestTable ORDER BY Chanpin DESC;", $hQuery)
        
        While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
                
                GUICtrlCreateListViewItem($aRow & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)
                
        WEnd
        _SQLite_Close()
        
        
EndFunc   ;==>Form1Close
 楼主| 发表于 2012-4-22 09:13:04 | 显示全部楼层
chanpin        TEXT        0        0        -1        0                        0
jiage        TEXT        0        0        -1        0                        0
shijian        TEXT        0        0        -1        0                        0
发表于 2012-4-22 09:16:45 | 显示全部楼层
回复 4# xin266


    速度还真快!马上看!
发表于 2012-4-22 09:28:29 | 显示全部楼层
本帖最后由 hzxymkb 于 2012-4-22 09:29 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include<date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Global $Msg, $hQuery, $aRow
$SQLite_Data_Path = "360.db"
Opt("GUIOnEventMode", 1)
_SQLite_Startup()
#Region ### START Koda GUI section ### Form=C:\Users\changxin\Desktop\study\京东价格\Form1.kxf
$Form1 = GUICreate("京东历史价格工具", 895, 438, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$ListView1 = GUICtrlCreateListView("编号|价格|产品|日期", 0, 0, 745, 321)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 550)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 90)
$Label1 = GUICtrlCreateLabel("产品网址", 16, 344, 52, 17)
$Input1 = GUICtrlCreateInput("", 72, 344, 473, 31)
$Button1 = GUICtrlCreateButton("确定", 592, 344, 97, 49)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
While 1

        Sleep(100)
WEnd


Func Button1Click()

        $now = _Now()
        $url = GUICtrlRead($Input1)
        $oHTTP = ObjCreate("microsoft.xmlhttp")
        $oHTTP.open("get", $url, False)
        $oHTTP.send()
        $source2 = $oHTTP.responsetext

        $price = StringRegExp($source2, "我在@京东商城 发现了一个非常不错的商品:(.+),京东价:¥(\d+\.\d+)", 3)
        
        _SQLite_Open($SQLite_Data_Path)
        _SQLite_Exec(-1, "Insert into TestTable (Chanpin) values ('" & $price[0] & "');")


        _SQLite_Exec(-1, "UPDATE TestTable SET Jiage = '" & $price[1] & "' WHERE Chanpin = '" & $price[0] & "';")

        _SQLite_Exec(-1, "UPDATE TestTable SET Shijian = '" & $now & "' WHERE Chanpin = '" & $price[0] & "';")

        _SQLite_Close()

EndFunc   ;==>Button1Click
Func Form1Close()
        _SQLite_Open($SQLite_Data_Path)
        _SQLite_Query(-1, "SELECT * FROM TestTable;", $hQuery)

        While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
                GUICtrlCreateListViewItem($aRow[0] & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)

        WEnd
        _SQLite_Close()


EndFunc   ;==>Form1Close
发表于 2012-4-22 15:58:31 | 显示全部楼层
本帖最后由 netegg 于 2012-4-22 16:07 编辑

$aRow是什么东西,没找到赋值的部分

回复 6# hzxymkb
你运行了吗,就把代码发上来
 楼主| 发表于 2012-4-22 19:29:05 | 显示全部楼层
没啥反应哦
发表于 2012-4-22 20:37:20 | 显示全部楼层
回复 8# xin266
不是说了吗,那个$aRaw是什么东西,赋值的部分在什么地方
 楼主| 发表于 2012-4-22 21:35:29 | 显示全部楼层
回复 9# netegg


    其实是想写一个读取数据库里面的东西 到listview上面
发表于 2012-4-22 21:53:33 | 显示全部楼层
回复 10# xin266
想干什么是你操作的选择,解释的是你说的出错的问题
发表于 2012-4-22 22:02:09 | 显示全部楼层
回复 10# xin266
SQLite数据库,论坛有例子的,搜搜看!
 楼主| 发表于 2012-4-23 08:07:33 | 显示全部楼层
回复 9# netegg


    $aRaw是一个数组 存储从数据库里面读取的数据
发表于 2012-4-23 08:44:09 | 显示全部楼层
本帖最后由 netegg 于 2012-4-23 08:51 编辑

回复 13# xin266
定义呢,赋值呢,不是说你认为是数据库数据就是了,变量又不会自己去读,你不指定的话变量就只是个变量
看你的代码,除了一个global,和最后的引用,$aRaw根本就没值
如果你认为读到了,那么在子函数的第一行加句,msgbox(0,0,ubound($aRaw))或者msgbox(0,0,isarray($aRaw))看看返回值就知道了
 楼主| 发表于 2012-4-23 09:14:56 | 显示全部楼层
回复 14# netegg


     While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK

这一句是赋值的

但是可能写的有问题
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 20:50 , Processed in 0.088393 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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