如何将数据表从不同的数据库保存到SQLite [英] how to Save a Datatable from a different database to SQLite

查看:74
本文介绍了如何将数据表从不同的数据库保存到SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此子程序保存数据表但我总是得到SQL语法错误

hi m using this subroutine to save a datatable but i always get a SQL syntax error

Public Sub SaveDt(ByRef dt As DataTable, ByVal DatabaseFile As String)
        

            If My.Computer.FileSystem.FileExists(DatabaseFile) Then       
            My.Computer.FileSystem.DeleteFile(DatabaseFile)
            End If

            SQLiteConnection.CreateFile(DatabaseFile)

        Try
            dbLiteConn = New SQLiteConnection(setConn_Lite(DatabaseFile))

            dbLiteComd = dbLiteConn.CreateCommand()
            dbLiteComd.CommandText = String.Format("SELECT * FROM {0}", dt.TableName)

            dbLiteAdapt = New SQLiteDataAdapter(dbLiteComd)
            Dim dbLitebuilder As New SQLiteCommandBuilder(dbLiteAdapt)

            dbLiteAdapt.Update(dt)

            dbLiteConn.Close()

        Catch Ex As Exception
            MessageBox.Show(Ex.Message)
        End Try

    End Sub

推荐答案

I建议阅读这些文章:

C#:避免SQLite中插入的性能问题 [ ^ ]

SQLite中的批量操作和带有事务的C#[ ^ ]
I'd suggest to read these articles:
C#: Avoiding Performance Issues with Inserts in SQLite[^]
Bulk Operations in SQLite and C# with Transaction[^]


这篇关于如何将数据表从不同的数据库保存到SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆