本帖最后由 sour 于 2011-11-12 19:03 编辑
刚刚开始用数据库不太熟悉,用sqlite读出来然后到listview死活不对,我开始还以为是数据库的问题,把数据库字型从text变成数字又变成自增加,数据库里面排列挺好,但是到listview就是1,10,11这样排列了,我用msgbox读了一下发现读出来是正确的顺序,但是写进去不行,又改变了listview写入的方法也不行,但是只要把第一列的不用数据库读出来的东西,用一个固定数字就会好,是我listview设置不对还是什么原因Func SQLiteRead()
_GUICtrlListView_DeleteAllItems ( GUICtrlGetHandle ($GUI_ListBox) )
_SQLite_Open ($SQLite_Data_Path)
_SQLite_Query(-1, "SELECT * FROM parts ORDER BY IDs desc ;",$hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
GUICtrlCreateListViewItem($aRow[0]&"|"&$aRow[1]&"|"&$aRow[2]&"|"&$aRow[3]&"|"&$aRow[4], $GUI_ListBox)
;GUICtrlCreateListViewItem($id & '|'& $Name & '|'&$Tel, $ListView1 )
; _GUICtrlListView_AddItem($GUI_ListBox, $aRow[0])
; _GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[1], 1)
; _GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[2], 2)
;_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[3], 3)
;_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[4], 4)
WEnd
;_GUICtrlStatusBar_SetText ($StatusBar1," 共找到 "&_GUICtrlListView_GetItemCount($listview1)&" 条记录 ")
_SQLite_Close ()
EndFunc
顺序变成这样
前面加一个数字就ok
|