已经解决 帮忙看看sqlite读取数据到 listview
本帖最后由 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 & "|" & "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 & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)
WEnd
_SQLite_Close() 发完整的代码和数据库上来! 回复 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 & "');")
_SQLite_Exec(-1, "UPDATE TestTable SET Jiage = '" & $price & "' WHERE Chanpin = '" & $price & "';")
_SQLite_Exec(-1, "UPDATE TestTable SET Shijian = '" & $now & "' WHERE Chanpin = '" & $price & "';")
_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
chanpin TEXT 0 0 -1 0 0
jiage TEXT 0 0 -1 0 0
shijian TEXT 0 0 -1 0 0
回复 4# xin266
速度还真快!马上看! 本帖最后由 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 & "');")
_SQLite_Exec(-1, "UPDATE TestTable SET Jiage = '" & $price & "' WHERE Chanpin = '" & $price & "';")
_SQLite_Exec(-1, "UPDATE TestTable SET Shijian = '" & $now & "' WHERE Chanpin = '" & $price & "';")
_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 & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)
WEnd
_SQLite_Close()
EndFunc ;==>Form1Close
本帖最后由 netegg 于 2012-4-22 16:07 编辑
$aRow是什么东西,没找到赋值的部分
回复 6# hzxymkb
你运行了吗,就把代码发上来 没啥反应哦{:face (229):} 回复 8# xin266
不是说了吗,那个$aRaw是什么东西,赋值的部分在什么地方 回复 9# netegg
其实是想写一个读取数据库里面的东西 到listview上面 回复 10# xin266
想干什么是你操作的选择,解释的是你说的出错的问题 回复 10# xin266
SQLite数据库,论坛有例子的,搜搜看! 回复 9# netegg
$aRaw是一个数组 存储从数据库里面读取的数据 本帖最后由 netegg 于 2012-4-23 08:51 编辑
回复 13# xin266
定义呢,赋值呢,不是说你认为是数据库数据就是了,变量又不会自己去读,你不指定的话变量就只是个变量
看你的代码,除了一个global,和最后的引用,$aRaw根本就没值
如果你认为读到了,那么在子函数的第一行加句,msgbox(0,0,ubound($aRaw))或者msgbox(0,0,isarray($aRaw))看看返回值就知道了 回复 14# netegg
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
这一句是赋值的
但是可能写的有问题
页:
[1]
2