以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教狐表支持SQLite数据库吗?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=16432)

--  作者:fyqingshan
--  发布时间:2012/2/14 9:42:00
--  请教狐表支持SQLite数据库吗?
请教狐表支持SQLite数据库吗? 学狐表还需要学习vb语言吗?
--  作者:狐狸爸爸
--  发布时间:2012/2/14 9:45:00
--  

1、支持Access\\SQL Server\\Oracle

2、不需要学习vb,学foxtable的帮助文件足矣。


--  作者:fyqingshan
--  发布时间:2012/2/14 9:53:00
--  
能把编程语言中文化更好呀
--  作者:hunanwl
--  发布时间:2013/9/11 14:18:00
--  
那 我要怎么弄才能支持SQLite数据库呢,添加外部引用文件可以解决吗,狐爸帮忙想想办法啊

最好是可以动态的支持任何数据库就最好了
[此贴子已经被作者于2013-9-11 14:19:21编辑过]

--  作者:Bin
--  发布时间:2013/9/11 14:20:00
--  
没有办法支持哦!
--  作者:逛逛
--  发布时间:2013/9/11 15:43:00
--  
以下是引用hunanwl在2013-9-11 14:18:00的发言:
那 我要怎么弄才能支持SQLite数据库呢,添加外部引用文件可以解决吗,狐爸帮忙想想办法啊

[此贴子已经被作者于2013-9-11 14:19:21编辑过]

添加System.Data.SQLite.dll


--  作者:hunanwl
--  发布时间:2013/9/11 16:35:00
--  

已经添加了  接下来我该怎么连接SQLite数据库呢


--  作者:hunanwl
--  发布时间:2013/9/11 16:36:00
--  
以下是引用逛逛在2013-9-11 15:43:00的发言:

添加System.Data.SQLite.dll

已经添加了 接下来我该怎么连接SQLite数据库呢


--  作者:逛逛
--  发布时间:2013/9/11 16:56:00
--  

三个基本操作:

1、新建数据库(自定义函数)

\'传入1个参数,数据库全路径
Dim Path As String = Args(0)
Dim b As System.Data.SQLite.SQLiteException
\'成功返回1,失败返回-1
If System.IO.File.Exists(Path) = True Then
    MessageBox.show("已有同名的数据库存在.")
    Return -1
End If
Using myData As New System.Data.SQLite.SQLiteConnection( "data source=" &  Path)
Try
    myData.Open()
    myData.Close()
    SaveConfigValue("目标数据库",Path )
    Return 1
Catch b
    Throw New System.Data.SQLite.SQLiteException(b.Message)
    Return -1
End Try
End Using

 

2、执行SQL(自定义函数)

\'传入文本型,SQL语句,返回1,失败返回-1
Dim sql As String = Args(0)
Dim Path As String =  GetConfigValue("目标数据库", "无")  \'我是将路径存放在这里,根据需要改
If Path = "无" Then
    MessageBox.show("请定位数据库.")
    Return Nothing
End If

\'定义一个数据库连接,使用后立即释放
Using connection As New System.Data.Sqlite.SQLiteConnection("data source=" & Path)
Using cmd As New System.Data.Sqlite.SQLiteCommand(sql, connection)
Try
    connection.Open()
    cmd.ExecuteNonQuery()
    Return 1
Catch e As System.Data.Sqlite.SQLiteException
    connection.Close()
    Throw New System.Data.Sqlite.SQLiteException(e.Message)
    Return -1
End Try
End Using
End Using

 

3、取记录集(自定义函数)

\'传入文本型,SQL语句,返回DataTable,失败返回Nothing
Dim sql As String = Args(0)
Dim Path As String =  GetConfigValue("目标数据库", "无")
If Path = "无" Then
    MessageBox.show("请定位数据库.")
    Return Nothing
End If
Using  connection As New System.Data.SQLite.SQLiteConnection("data source=" & Path)
Dim ds As New System.Data.DataSet()
Try
    connection.Open()
    Dim command As New System.Data.SQLite.SQLiteDataAdapter(sql, connection)
    command.Fill(ds, "ds")
    Return ds.Tables(0)
Catch ex As System.Data.SQLite.SQLiteException
    Throw New Exception(ex.Message)
    Return Nothing
End Try
End Using

 

 

 

不过,狐表的Access不需安装就可使用,没有必要用Sqlite


--  作者:hunanwl
--  发布时间:2013/9/11 17:27:00
--  
以下是引用逛逛在2013-9-11 16:56:00的发言:

三个基本操作:

1、新建数据库(自定义函数)

\'传入1个参数,数据库全路径
Dim Path As String = Args(0)
Dim b As System.Data.SQLite.SQLiteException
\'成功返回1,失败返回-1
If System.IO.File.Exists(Path) = True Then
    MessageBox.show("已有同名的数据库存在.")
    Return -1
End If
Using myData As New System.Data.SQLite.SQLiteConnection( "data source=" &  Path)
Try
    myData.Open()
    myData.Close()
    SaveConfigValue("目标数据库",Path )
    Return 1
Catch b
    Throw New System.Data.SQLite.SQLiteException(b.Message)
    Return -1
End Try
End Using

 

2、执行SQL(自定义函数)

\'传入文本型,SQL语句,返回1,失败返回-1
Dim sql As String = Args(0)
Dim Path As String =  GetConfigValue("目标数据库", "无")  \'我是将路径存放在这里,根据需要改
If Path = "无" Then
    MessageBox.show("请定位数据库.")
    Return Nothing
End If

\'定义一个数据库连接,使用后立即释放
Using connection As New System.Data.Sqlite.SQLiteConnection("data source=" & Path)
Using cmd As New System.Data.Sqlite.SQLiteCommand(sql, connection)
Try
    connection.Open()
    cmd.ExecuteNonQuery()
    Return 1
Catch e As System.Data.Sqlite.SQLiteException
    connection.Close()
    Throw New System.Data.Sqlite.SQLiteException(e.Message)
    Return -1
End Try
End Using
End Using

 

3、取记录集(自定义函数)

\'传入文本型,SQL语句,返回DataTable,失败返回Nothing
Dim sql As String = Args(0)
Dim Path As String =  GetConfigValue("目标数据库", "无")
If Path = "无" Then
    MessageBox.show("请定位数据库.")
    Return Nothing
End If
Using  connection As New System.Data.SQLite.SQLiteConnection("data source=" & Path)
Dim ds As New System.Data.DataSet()
Try
    connection.Open()
    Dim command As New System.Data.SQLite.SQLiteDataAdapter(sql, connection)
    command.Fill(ds, "ds")
    Return ds.Tables(0)
Catch ex As System.Data.SQLite.SQLiteException
    Throw New Exception(ex.Message)
    Return Nothing
End Try
End Using

 

 

 

不过,狐表的Access不需安装就可使用,没有必要用Sqlite

还是一头雾水 呵呵

不是说Sqlite速度稳定性比Access好吗 网上说access到100M后速度下降好的