|

楼主 |
发表于 2015-1-14 17:59:00
|
显示全部楼层
gaofan628 发表于 2015-1-14 12:16 
不可能,select * from table,, 这不可能错吧
只要能打开数据库 应该就没问题。。 看看你代码吧。。 下面一个例子- Private Sub Command1_Click()
- Dim hstmt As Long
- Dim Script As String
- Dim pReturn As SQLITE_RETURN
- Dim hdb As Long
- Dim i As Long
- Dim iCount As Long
- Dim Table_count As Long
- Dim Char As String
- Call sqlite_open("Test.sqlite", hdb)
- Rem 获取选中表的总条目数
- Script = "select count(*) from StdItems where Idx>0"
- pReturn = sqlite_prepare(hdb, Script, hstmt)
- If pReturn = SQLITE_OK And sqlite_next(hstmt) Then
- iCount = sqlite_column_int(hstmt, 0)
- sqlite_step hstmt
- sqlite_finalize hstmt
- End If
- Rem 获取选中表 Idx > 0 的条目信息
- ' Script = "select * from StdItems where Idx > 0"
- Rem 获取选中表 Idx > 0 的条目信息 并按Idx进行由低到高排序( 加上desc 由高到低排序)
- Script = "select * from StdItems where Idx > 0 order by Idx"
- pReturn = sqlite_prepare(hdb, Script, hstmt)
- If pReturn = SQLITE_OK Then
- Debug.Print "[" & iCount & "]"
- Debug.Print "{"
- Table_count = sqlite_column_count(hstmt)
- ' For I = 0 To Table_count - 1
- ' Debug.Print sqlite3_column_name(hstmt, I)
- ' Next
- Do While sqlite_next(hstmt)
- Char = ""
- For i = 0 To Table_count - 1
- Char = Char & sqlite_column_text(hstmt, i) & " "
- Next
- Debug.Print Char
- Loop
- sqlite_step hstmt
- sqlite_finalize hstmt
- End If
- Rem 列出指定条目
- Script = "select * from StdItems where Idx = 5"
- pReturn = sqlite_prepare(hdb, Script, hstmt)
- If pReturn = SQLITE_OK Then
- Table_count = sqlite_column_count(hstmt)
- If sqlite_next(hstmt) Then
- Char = ""
- For i = 0 To Table_count - 1
- Char = Char & sqlite_column_text(hstmt, i) & " "
- Next
- Debug.Print "}"
- Debug.Print Char
- End If
- sqlite_step hstmt
- sqlite_finalize hstmt
- End If
- sqlite_close hdb
- End Sub
复制代码 |
|