Android Tutorial SQL tutorial

Discussion in 'Tutorials & Examples' started by Erel, Dec 2, 2010.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    Yes. See the example in the first post (ExecQuery2 or ExecNonQuery2).
     
  2. notedop

    notedop Member Licensed User

    As a tip if you would like to pre-fill data with Microsoft access, you can use sqlite ODBC to connect to your created sqlite database and pre-fill. Then you can transfer the database to your application for further usage.
    link to the odbc dll.
    http://www.ch-werner.de/sqliteodbc/
     
  3. JForge

    JForge Member Licensed User

    Here's a small quirk, when i sort an SQL query by a text field, it treats something in lower case differently than everything else that is in upper case.

    So when I sort a list of names ascending, the name that starts with a lower case b ends up at the very end...

    any ideas?

    Thanks!
    -John
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    "SELECT * FROM table1 ORDER BY col COLLATE NOCASE"
     
  5. jcredk

    jcredk Member Licensed User

    Hello,
    Just a simple (stupid) question does sqllite handle "Like" in "where" clauses ?
    Could you give me a sample please ?
    Thanks
    Jo
     
  6. MaFu

    MaFu Well-Known Member Licensed User

    Code:
    Dim namePart As String = "Erel"
    Dim cur As Cursor = SQL.ExecQuery("SELECT * FROM yourtablenamehere WHERE yourcolumnnamehere like '%" & namePart & "%'")
     
    Last edited: Oct 3, 2013
  7. jcredk

    jcredk Member Licensed User

    Thanks it cannot be more clear ...!
     
  8. luke2012

    luke2012 Well-Known Member Licensed User

    Hi Erel,
    is there a size limit for the image using InsertBlob function ?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

  10. TEEGEE

    TEEGEE New Member Licensed User

    the system does not support all character?


    android.database.sqlite.SQLiteException: near "ñåìàâè¿èóóäæñîèæøññäèçó": syntax error: INSERT INTO tblUsers VALUES('2',''','ñåìàâè¿èóóäæñîèæøññäèçó','î²æè±ó')
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Try this query:
    Code:
    SQL.ExecuteNonQuery("INSERT INTO tbleUsers VALUES(?, ?, ?)"Array As Object("2""""ñåìàâè¿èóóäæñîèæøññäèçó""î²æè±ó"))
     
  12. TEEGEE

    TEEGEE New Member Licensed User

    THX Erel
     
  13. merlin2049er

    merlin2049er Well-Known Member Licensed User


    I'm using the Cursor1.GetString("col1") to get fields from my db table, but it's crashed when that field is empty.
     
  14. klaus

    klaus Expert Licensed User

    Try this code:
    Code:
    str = Curs.GetString("col1")
    If str <> Null Then
        
    ' your code
    End If
    Depending how you filled the database empty fields can be 'Null'.
     
  15. merlin2049er

    merlin2049er Well-Known Member Licensed User

    Thanks. I should have know that.
     
  16. Vincenzo Fabiano

    Vincenzo Fabiano Member Licensed User

    Sorry .. it is usually advisable to open the connection and leave it open, or open and close it every time you need to do the operations? Assuming that currently every few seconds my application needs to access certain data .. In my case the query "continue" to have the best performance, you should leave the connection open and close it only at the end or open and close all the time? Sorry for my bad English.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    Normally you should open it once and keep it open as long as your app is running or until the connection is no longer required.
     
    Vincenzo Fabiano likes this.
  18. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  19. 3394509365

    3394509365 Active Member Licensed User

    Hello everyone, when I load the program I would like to see in a listview 's list of the tables in my database.
    I'm trying so but I do not know how to proceed,

    Code:
    SQLDataBasePath As String Dim = File.DirDefaultExternal
    Dim SQLDateBaseName = "xxx.db" As String


        
    Dim cur As Cursor
        
    Dim SQL As SQLdb
        
    Dim Cursor As Curs
        
    Dim strQuery As String
     
        strQuery = 
    "SELECT name FROM sqlite_master WHERE type = 'table'"
    sqlDB.Initialize (SQLDataBasePath, SQLDateBaseName, 
    True)

    'Up to here works

    Curs = sqlDB.ExecQuery (strQuery)
    ListView1.AddSingleLine (Curs)

    Curs.Close
    pleace
     
  20. LucaMs

    LucaMs Expert Licensed User

Thread Status:
Not open for further replies.
Loading...
  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