Hi and welcome to Basic4ppc.
- Yes. For example if we have a module named 'Module1' and a form named 'Form1':
B4X:
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
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 ??
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.
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.
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
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):
B4X:
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