分享

VFB_测试sqlite3类

 nxhujiee 2020-07-09
 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command1_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
If SQLite31.Open(App.Path "sqlite3_test.db", ""False Then
        Print 
"打开数据库成功"
    Else
        Print 
"打开数据库失败 SQLite31.ErrMsg
    End If
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command2_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
If SQLite31.SetKey("123456"False Then Print SQLite31.ErrMsg
    Print "修改密码"
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command3_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Dim 
As Long SQLite31.SqlFind("SELECT FROM features WHERE id=100", rs())
    
Dim As Long x,y
    If Then Print SQLite31.ErrMsg
    Print UBound(rs), UBound(rs, 2)
    
For To UBoundrs)
        
For To UBound(rs, 2)
            
Print rs(y, x ,
        
Next
        Print
    Next
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command4_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Dim 
As Long SQLite31.Find("features", "id>0", rs())
    
Dim As Long x,y
    If Then Print SQLite31.ErrMsg
    Print UBound(rs), UBound(rs, 2)
    
For To UBoundrs)
        
For To UBound(rs, 2)
            
Print Utf8toStr(rs(y, x)),
        
Next
        Print
    Next
    
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command5_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Dim 
As Long SQLite31.FindOne("features", "id=2", rs())
    
Dim As Long x,y
    If Then Print SQLite31.ErrMsg
    Print "字段数:UBound(rs1
    For To UBound(rs)
        
Print Utf8toStr(rs(x))
    
Next
    Print
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command6_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
If SQLite31.SetKey(""False Then Print SQLite31.ErrMsg
    Print "清除密码"
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command7_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.AddItem ("features", "title=100,description='dd''d'")
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command8_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.Update ("features","id=2", "description='更新内容'")
    
Print SQLite31.ErrMsg
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command9_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print "数据库引擎版本:SQLite31.Version
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command10_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Dim 
As Long SQLite31.SqlFind("PRAGMA  table_info('features') ", rs())  features 为表名称
    
Dim As Long x,y
    If Then Print SQLite31.ErrMsg
    Print UBound(rs), UBound(rs, 2)
    
For To UBoundrs)
        
For To UBound(rs, 2)
            
Print Utf8toStr(rs(y, x)),
        
Next
        Print
    Next
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command11_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Print 
SQLite31.INIsetKey("软件配置", "测试项目", "测试值")
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command12_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Print 
SQLite31.INIgetKey("软件配置", "测试项目", "默认值")
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command13_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Dim 
id As Long SQLite31.MaxID("features", "id")
    
If id Then
        Print 
SQLite31.ErrMsg
    Else
        Print 
"删除ID=id
        Print SQLite31.DeleteItem("features", "id=id)
    
End If
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command14_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.Count("features")
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command15_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim id As Long SQLite31.AddItem("[二进制]", "aaa=100"  '为了避免表名称或字段名称与SQL内部名称冲突,可以用[] 括在中间,中文更应该括起来
    
If id Then
        Print 
"出错:SQLite31.ErrMsg
    Else
        Dim 
by(10As UByte
        For As Long To 10
            by(iInt(Rnd 255)
            
Print Hex(by(i), 2" ;
        Next
        Print
        Print 
SQLite31.UpdateByte("[二进制]", "ID=id, "[数据]", @by(0), 11 '为了避免表名称或字段名称与SQL内部名称冲突,可以用[] 括在中间,中文更应该括起来
        
Print "出错:SQLite31.ErrMsg
    End If
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command16_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim rs() As String
    Dim 
As Long SQLite31.Find("[二进制]", "", rs()) '为了避免表名称或字段名称与SQL内部名称冲突,可以用[] 括在中间,中文更应该括起来
    
Dim As Long x,y ,i
    If Then Print SQLite31.ErrMsg
    Print UBound(rs), UBound(rs, 2)
    
For To UBoundrs)
        
For To UBound(rs, 2)
            
If And Then
                Dim 
ss As String
                For 
To Len(rs(y, x)) 1
                    ss  Hex(rs(y, x)[i], 2"    String 可以包含任意值,当然可以是2进制数据了
                
Next
                Print 
ss,
            Else
                Print 
rs(y, x),
            
End If
        Next
        Print
    Next
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command17_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.Vacuum
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command18_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
SQLite31.TransactionBegin   事务开始(用于批量执行SQL,提高SQL效率)
    
Dim As Long
    
For To 100
        SQLite31.AddItem("features", "title=",description='Rnd "'")
    
Next
    Print 
SQLite31.TransactionEnd 事务执行并且结束
    
Print "ok"
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command19_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.CreateTable("[创建的新表]")
    
Print "出错:SQLite31.ErrMsg
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command20_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.AddField("[创建的新表]", "[新字段]", "TEXT","'dd'")
    
Print "出错:SQLite31.ErrMsg
End Sub

 单击 [事件]   ControlIndex=控件数组的索引  hWndForm=窗体句柄  hWndControl=控件句柄  ionControl=按钮的标识符
Sub Form1_Command21_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Print SQLite31.CreateIndex("[创建的新表]", "[新字段]", True)
    
Print "出错:SQLite31.ErrMsg
End Sub

Sub 
Form1_Shown(hWndForm As hWnd,UserData As Integer)  '窗口完全显示后。UserData 来自显示窗口最后1个参数。
End Sub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多