Android Question Sqlite /SQL Server

Discussion in 'Android Questions' started by Pilar-JLSineriz, Jul 21, 2015.

  1. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User


    I am making an APK that works with a database SQLITE. I want to design a button in the APK that transform the SQLITE file in a SQL file that can be to read by SQL Server.

    For example, I am taking data about the properties of the different mineral waters and the data are stored in a SQLITe database, but I want that the database can be read in SQL Server. I want to put a button in the APK so that when the user finishs to take data, push the bottom and the APK generates a SQL file with the mineral waters data, that the user can be to send it by email or copy in a pen-drive so after it can be copied in the Server and it can be read with SQL Server.

    Many thanks
  2. cimperia

    cimperia Active Member Licensed User

    There are a few ways to do just that.

    Here is a simple implementation based on SQL Server CSV Import.

    First generate a CSV file from your app and then import it into your SQLSERVER database.

    To handle rows which aren't loaded into the table because of invalid data or format, could be handle using ERRORFILE property, specify the error file name, it will write the rows having error to error file. code could look like.

    BULK INSERT MineralWaterTable
      FIRSTROW = 
    ',',  --CSV field delimiter
      ROWTERMINATOR = '\n',  --Use to shift the control to next row
      ERRORFILE = 'C:\CSVData\mineralWatersErrorRows.csv',
  3. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Thanks.. I am going to try with this but I don´t know if I have success.. what happen when the DB has more tables than one? Have I repeat the instruction several times? Moreover, my initial file is SQLite not csv
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice