Dim db,timerRef
Sub Main
End Sub
Function Button1_oncllick()
db = SqlOpenDatabase("students.db")
sqlList=[]
sqlList[0]=["CREATE TABLE studentData('name','age',PRIMARY KEY('name'));",success,fail]
Sql(db,sqlList)
End Function
Sub success()
End Sub
Sub fail()
End Sub
'save
Function Button1_oncllick()
If txtName.value="" Then Exit Function
sqlList[0] = ["INSERT INTO studentData (name,age) ,VALUES (?,?);", [txtName.value,txtAge.value]]
Sql(db,sqlList)
End Function
'find
Function Button2_oncllick()
sqlList=[]
sqlList[0]=["SELECT * FROM studentData WHERE name=?",txtFind.value,nameFound], txtFind.value & "'",nameFound
Sql(db,sqlList)
End Function
Function nameFound(transaction,results)
If results.rows.length>0 Then
MsgBox results.rows.item(0).name & " is " & results.rows.item(0).age
Else
MsgBox "Name not found"
End If
End Function
'del
Function Button3_oncllick()
sqlList=[]
sqlList[0]=["DELETE FROM studentData WHERE name=?",txtFind.value,nameDeleted]
Sql(db,sqlList)
End Function
Function nameDeleted()
MsgBox txtFind.value & " Deleted"
End Function
```
Tip: If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly.
It looks like you are trying to use regular ticks (‘‘‘) not back ticks. (```)
Hi,just curious,would anyone help me out?
Can you start by fixing the formatting of your code snippet?
It would also help if you could clearly state what your question is.
Name : a
Age" : 3
Clear name
Clear age
Name b
Age : 5
Find : a
Click find
No output at all,I would expect : found a !,age 3(done with code formatting)
sqlList[0]=[“SELECT * FROM studentData WHERE name=?”,txtFind.value,nameFound]
txtFind.value & “'”,nameFound
The weird thing with this sample is the find button code,have 2 txt.find value,on different line.n with no ‘,’ in between. Hope u would take a look..thanks in advance,tst
Sorry to take your precious time looking at old code,cause I don’t know how to change the I loop display of sqlite sample in nsb app studio to something usable for me…
Can you start by fixing the formatting of your code snippet?
It would also help if you could clearly state what your question is.
Dim db,timerRef
Sub Main
End Sub
Sub waiting1()
db = SqlOpenDatabase(“students.db”)
sqlList=
sqlList[0]=[“CREATE TABLE studentData(‘name’,‘age’,PRIMARY KEY(‘name’));”,success,fail]
Sql(db,sqlList)
End Sub
Sub success()
End Sub
Sub fail()
End Sub
'save
Function Button1_oncllick()
If txtName.value=“” Then Exit Function
sqlList[0] = [“INSERT INTO studentData (name,age) ,VALUES (?,?);”, [txtName.value,txtAge.value]]
Sql(db,sqlList)
End Function
'find
Function Button2_oncllick()
sqlList=
sqlList[0]=[“SELECT * FROM studentData WHERE name=?”,txtFind.value,nameFound]
txtFind.value & “'”,nameFound
Sql(db,sqlList)
End Function
Function nameFound(transaction,results)
If results.rows.length>0 Then
MsgBox results.rows.item(0).name & " is " & results.rows.item(0).age
Else
MsgBox “Name not found”
End If
End Function
'del
Function Button3_oncllick()
sqlList=
sqlList[0]=[“DELETE FROM studentData WHERE name=?”,txtFind.value,nameDeleted]
Sql(db,sqlList)
End Function
Function nameDeleted()
MsgBox txtFind.value & " Deleted"
End Function
Function Button4_onclick()
waiting1()
End Function
Name : a
Age" : 3
Clear name
Clear age
Name b
Age : 5
Find : a
Click find
No output at all,I would expect : found a !,age 3(done with code formatting)
----------------------------------------------------------------
sqlList[0]=[“SELECT * FROM studentData WHERE name=?”,txtFind.value,nameFound] txtFind.value & “'”,nameFound
The weird thing with this sample is the find button code,have 2 txt.find value,on different line.n with no ‘,’ in between. Hope u would take a look..thanks in advance,tst
Sorry to take your precious time looking at old code,cause I don’t know how to change the I loop display of sqlite sample in nsb app studio to
something usable for me…
Can I call your attention to this again?
Is it better now?
Or perhaps,in future nsb appstudio app ;create a new SQL lite wasm sample that looks something like this layout.ie. simple to understand,pls don’t use i loop for variable.thanks in advance,tst
I don’t see any change. You can go to your first post and edit it, fixing your use of back ticks. (```)
How ABT now?
```
Dim db,timerRef
Sub Main
End Sub
Sub waiting1()
db = SqlOpenDatabase(“students.db”)
sqlList=
```
I only could do this,seems that I couldn’t paste code,after first ``` .I would be able to do it if I write code by code..sorry to dismay u….,tst
I know what the final render would look like,just couldn’t made all code arranged in the grey background,just couldn’t made it
Here’s a step by step:
- Go into your first post.
- Delete the code which is there.
- From AppStudio, copy the code you want to paste. Make sure it has all the indentation and formatting you want.
- In the Forum, edit your message.
- Enter ```, return, then paste the code
Done….,tst
Thanks to @ghenne
I used to click on the clipboard text in the keyboard window, where in this case,is wrong.i should press and hold the post,then paste.
Thank you! Your code is now easy to read.
It would also help if you could clearly state what your question is - I am not sure what you are asking.
Name : a
Age" : 3
Clear name
Clear age
Name b
Age : 5
Find : a
Click find
No output at all,I would expect : found a !,age 3(done with code formatting)
----------------------------------------------------------------
sqlList[0]=[“SELECT * FROM studentData WHERE name=?”,txtFind.value,nameFound] txtFind.value & “'”,nameFound
The weird thing with this sample is the find button code,have 2 txt.find value,on different line.n with no ‘,’ in between. Hope u would take a look..thanks in advance,tst
Sorry to take your precious time looking at old code,cause I don’t know how to change the I loop display of sqlite sample in nsb app studio to
something usable for me…
Can you send me a minimal project I can try this on?
Already sent to nsb support mail