Some questions

Discussion in 'Questions (Windows Mobile)' started by newbie, Dec 13, 2008.

  1. newbie

    newbie Member Licensed User

    Hello,

    i have download the trial version to take a look of basic4ppc.
    Now i have as a newbie at this time two questions:

    - can i call from the main application a form from a module ?
    what is the syntax to do this ?

    - is there a possibility to work with tables that can have one ore more
    indexes ?

    - how can i search for a record using a index

    i use it for a application with more than 10.000 records and need speed.

    kind regards from germany
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Hi and welcome to Basic4ppc.
    - Yes. For example if we have a module named 'Module1' and a form named 'Form1':
    Code:
    Module1.Form1.Show
    - Basic4ppc supports SQLite tables.
    You can create any number of indexes in one table.
    - Searching is done with a SELECT query.
    The SQL language may look a little bit complex at the beginning however simple queries can be created very easily.
    Here is a useful tutorial: SQL Tutorial
     
  3. newbie

    newbie Member Licensed User

    more questiens

    Thanks,
    i have try to create a table like this

    CREATE DATABASE MDEdb
    CREATE TABLE ScanData
    ( Nummer Int Not NULL UNIQUE,
    EAN varchar(13) UNIQUE,
    Name varchar(30),
    Groesse varchar(10),
    Einheit varchar(4)
    Bisher Int,
    Menge Int
    )
    but i get comiler error ??

    how can i find a list of datatype-names

    kind regards
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the actual code?
    What compiler error do you get?
    Which version of Basic4ppc do you use?

    SQLite documentation: SQLite Documentation
     
  5. newbie

    newbie Member Licensed User

    Hallo Erel,

    the version is 6.50

    the code , see last mail

    the compiler error was "inavlid Number of parenthesis"
    for the line with the first Field-def

    kind regards
     
  6. Mr_Gee

    Mr_Gee Active Member Licensed User

    Code:
    CREATE DATABASE MDEdb

       CREATE TABLE ScanData
          (   Nummer  Int       
    Not NULL UNIQUE,
              EAN    varchar(
    13)   UNIQUE,
             Name   varchar(
    30),
             Groesse   varchar(
    10),
             Einheit   varchar(
    4)
             Bisher   Int,
             Menge   Int
          )
    I think the problem lies with the "Create DB" command
    The DB will be created automatically if the SQLite db cannot be found.

    Personally I always create a DB with another (visual) SQLite manager
    and then I don't need to sc**w around with the above commands.


    Good Luck
     
  7. newbie

    newbie Member Licensed User

    the problem is compiling the code
    the compiler gives a error message "invalid number of parenthesis"
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    A string can't include more than a single line.
    You only posted your SQL code so I'm not sure if that is the problem, or not.
    A multiline string should be built with the concatenation character.
     
  9. newbie

    newbie Member Licensed User

    Hi Erel,

    that is the complete Code. Sorry, but i don't understand what you say.
    when id do it in one line i get a normal syntax error.
    what is the correct syntax to create a table, i don't found a example.

    Sub Form1_Show
    'create the Database and table
    CREATE DATABASE MDEdb
    CREATE TABLE MDEdb.ScanData
    ( Nummer Int Not NULL UNIQUE,
    EAN varchar(13) UNIQUE,
    Name varchar(30),
    Groesse Real,
    Einheit varchar(4),
    Bisher Int,
    Menge Int
    )
    End Sub


    kind regards
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    You are confusing between Basic4ppc language and SQL language.
    The way to work with SQL queries is to build a string that holds the query and then pass this string to a SQL Command object.

    The first steps that are required when working with the SQL library are:
    - Add a reference to SQLDesktop.dll and SQLDevice.dll.
    - Add a Connection object and a Command object.
    This is the code that builds your table (the program is attached):
    Code:
    Sub Globals
        
    'Declare the global variables here.

    End Sub

    Sub App_Start
        connection.New1
        connection.Open(
    "Data Source = " & AppPath & "\myDb.db")
        command.New1(
    "",connection.Value)
        CreateTable
        
        
    'Show the table
        command.CommandText = "SELECT * FROM ScanData"
        command.ExecuteTable(
    "table1",0)
        form1.Show
    End Sub

    Sub CreateTable
        command.CommandText = _
            
    "CREATE TABLE IF NOT EXISTS ScanData " & _
            
    "( Nummer Int Not NULL UNIQUE, " & _
            
    "EAN varchar(13) UNIQUE, " & _
            
    "Name varchar(30), " & _
            
    "Groesse Real, " & _
            
    "Einheit varchar(4), " & _
            
    "Bisher Int, " & _
            
    "Menge Int " & _
            
    ")"
        command.ExecuteNonQuery
    End Sub
     
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