The variable database table name is Text Event Main Window. Created() database table name = "mytable" End Event
Event button 4. Clicked () If the file exists (take the memory card path() > "/mydata.db") = false Create a database (take the card path () > "/mydata.db") A pop-up prompt ("Create database successful!") ) End If Open the database (take the card path() > "/mydata.db") '!! The database must be opened before performing any database operations A pop-up prompt ("Open database successful!") ) End Event
Event button 1. Clicked () If the data table exists (database table name) = false 'CREATE TABLE ' & Database table name & "(id text,value text)") 'Create a data table with two columns, the first column is id and the second column is value Create a data table (database table name, "id text, value text") If you want to create a self-incrementing id field, you can write Create Data Table (database table name, "id integer PRIMARY KEY, value text") A pop-up prompt ("Create datasheet successful!") ) Otherwise A pop-up prompt ("The datasheet already exists!") ) End If End Event
Event button 2. Clicked () ' Database Execution ("INSERT INTO " & Database Table Name & "VALUES ('1','zhangshang@163.com')") 'Insert records ' Database Execution ("INSERT INTO " & Database Table Name & " VALUES ('2','1234567@qq.com')") ' Database Execution ("INSERT INTO" & Database Table Name & "VALUES ('3','Lisi@126.com')") ' Database Execution ("INSERT INTO " & Database Table Name & " VALUES ('4','Wangwu@163.com')") Insert record (database table name, "'1','zhangshang@163.com'") Insert record (database table name, "'2','1234567@qq.com'") Insert record (database table name, "'3','Lisi@126.com'") Insert record (database table name, "'4','Wangwu@163.com'") 'If id is a self-incrementing field, it should be written like this Insert record (database table name, 'null,'Wangwu@163.com'") To insert the contents of the edit box, you can write like this: Insert record (database table name, "'" & edit box 1.content & "','" & edit box 2.content & "'") A pop-up prompt ("Insertion successful!") ) End Event
Event button 3. Clicked () 'Edit box 1.Content = database query("SELECT * FROM" & database table name & " WHERE id='1'","-","\n") 'Query id='1' for the record, the children of each record are separated by -, and the records are separated by line breaks 'Edit box 1.Content = conditional query (database table name, "id='1'", "-", "\n") If delete the beginning and end of the blank (edit box 2.content) = "" then Pop-up prompt ("Please enter query criteria") Exit End If Edit box 1.Content = conditional query(database table name,"id='" > delete the first and last spaces (edit box 2.content) > "'","-","\n") A pop-up prompt ("Query successful!") ) End Event
Event button 6. Clicked () 'Database execution ('UPDATE' & database table name > 'SET value='This is the modified value' WHERE id='1'") 'Modify id='1' for that record Modify the record (database table name, "value='This is the modified value'", "id='1'") A pop-up prompt ("Modified successfully!") ) End Event
Event button 5. Clicked () 'DELETE FROM' ("DELETE FROM" & database table name & " WHERE id='1'") 'delete the record id='1' Delete record (database table name, "id='1'") A pop-up prompt ("Deleted successful!") ) End Event
Event button 7. Clicked () 'DATABASE EXECUTION' ("DROP TABLE" > database table name) deletes the entire database table Deleting a Data Table (Database Table Name) A pop-up prompt ("Delete database table successful!") ) End Event
Event button 8. Clicked () Pop-up prompt ("Total number of records:" > Number of records (database table name) > "Items") End Event
Event button 9. Clicked () 'Edit box 1.Content = database query("SELECT * FROM" > database table name > "WHERE value LIKE '%163.com'","-","\n") 'Query all records with values ending in '163.com' Edit box 1. Content = conditional query (database table name, "value LIKE '%163.com'", "-", "\n") A pop-up prompt ("Query successful!") ) End Event
Event button 10. Clicked () 'Edit box 1.Content = database query("SELECT * FROM" > database table name & "LIMIT 0,3","-","\n") 'Query 3 records starting from 0 (1). Edit box 1. Content = Scope query (database table name, 0, 3, "-", "\n") A pop-up prompt ("Query successful!") ) End Event
Event button 11. Clicked () Close the database() '!! Close the database at the end of the program End Procedure () End Event |