PDA

View Full Version : مشکل در b4a و دریافت سطرهای دیتابیس



DR.HTML
یک شنبه 06 مهر 1393, 18:03 عصر
ا سلام یه مشکلی برام پیش اومده اونم میخوام لیست فیلدهای یه دیتابیسو بزارم توی یه button خوب این کد
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SQL As SQL
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim curs As Cursor
Private Panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout2")
If File.Exists(File.DirInternal,"shamloo.db")=False Then
File.Copy(File.DirAssets,"sd.db",File.DirInternal,"sd.db")
End If
If SQL.IsInitialized=False Then
SQL.Initialize(File.DirInternal,"shamloo.db",False)
End If
curs=SQL.ExecQuery("select * from poems where notebook='"&poem.mypoem&"'")
Dim h As Int
h=2%y
ToastMessageShow(curs.RowCount,True)
For i=0 To curs.RowCount-1
curs.Position=i
Dim btn As Button
btn.Initialize("btn")
btn.Text=curs.GetString("name")
btn.tag=i+1
Panel1.AddView(btn,0,h,50%x,10%x)
h=h+10%y
Next


End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

خوب مشکل اینه وقتی Select میکنه فقط یه سطر بر میگردونه مشکل از curs.Position=i نیست چون تعدا سطرهارو با rowcount میخونم اون 1 رو نشون میده یعنی کلا چیزیه که به دست اورده مشکل هم از query نیست چون همون query رو ران میکنم نتایج درستیه نشون میده مشکل کجاست باتشکر