in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

How to export a SQLite table to a CSV file and to a XLS file as well?

Last post 10-13-2011 5:29 PM by rose. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-22-2009 11:53 AM

    How to export a SQLite table to a CSV file and to a XLS file as well?

    I am working with SQLite and I am looking for some code that can help me to export a SQLite table from a

    Visual Studio Vb application to a CSV and a XLS file as well. 

    I also need the other way conversion meanning form XLS or CSV into a SQLite table.

    Any Ideas?

    Thanks in advance for your help.

    mprieto
    Filed under: , ,
  • 03-06-2009 6:01 AM In reply to

    • bmahf
    • Not Ranked
    • Joined on 03-05-2009
    • Posts 1

    Re: How to export a SQLite table to a CSV file and to a XLS file as well?

     I am very interested in the answer to this question as well.  Matter of fact, I am wanting to export the whole schema and data to a flat file that would allow for recreating the database as it stands, with all the necessary create and insert statements.  Is it necessary for me to roll my own on this one, or does somethign already exist.  I've roamed the net trying to find some information about this but haven't seen anything yet.  Basically, I need to be able to create a unit for an application that is able to create a new database with changes made given an existing database.  In other words, if I want to change table names or drop/add tables, I would like to be able to do so on the fly given some criteria, an existing database, and a destination for a new database.   Any help on this would be highly appreciated.  This is for a critical task that must be implemented shortly.

    Thanks for any help you can give...

  • 03-13-2009 6:59 AM In reply to

    • Astice
    • Not Ranked
    • Joined on 03-13-2009
    • Posts 1

    Re: How to export a SQLite table to a CSV file and to a XLS file as well?


    The follwing code is an example how to achieve the task.

     <Code>

    Imports System.Data
    Imports System.Data.SQLite


            Public Sub ExportToXML()

                Dim DBConnection As New SQLiteConnection
                With DBConnection
                    .ConnectionString = "Data Source=TEST.Sqlite"    '/ put in the name of your database
                    .Open()
                End With

                '/ put in the name of the table you want to export
                Dim DataAdapter As New SQLiteDataAdapter("SELECT * FROM [TestTable]", DBConnection) 

                Dim DBTable As New DataTable
                DBTable.TableName = "SQLiteTable"
                DBTable.Locale = System.Globalization.CultureInfo.InvariantCulture
                DataAdapter.Fill(DBTable)

                DBTable.WriteXml("C:\Test.XML", True)


            End Sub
    </Code>

     

    Cheers,

    Michael

  • 10-13-2011 5:29 PM In reply to

    • rose
    • Top 500 Contributor
    • Joined on 10-14-2011
    • Posts 7

    Re: How to export a SQLite table to a CSV file and to a XLS file as well?

    i already try the code and it function successfully, but what if i want to save the information and at same time the new information or data save at sqlite database and display at .xml file...

     

    seeking for answer...

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems