ببینید مشکل این سورس چیه که وقتی میخواد یه دیتابیس رو از سرور بگیره و با دیتابیس فعلی جایگزین کنه
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#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
Dim cur,cur2 As Cursor
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 hj As Int
Dim http As HttpJob
Private Button1 As Button
Private Label1 As Label
Private ListView1 As ListView
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("L1")
http.Initialize("job",Me)
http.Download("http://b4a1test.ihweb.ir/test.db")
If File.Exists(File.DirInternal,"test.db") = False Then
File.Copy(File.DirAssets,"test.db",File.DirInternal,"test.db")
End If
If sql.IsInitialized = False Then
sql.Initialize(File.DirInternal,"test.db",False)
End If
Button1.Text = "Show"
Button1.Enabled = False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
'cur = sql.ExecQuery("SELECT id FROM we")
''hj = Rnd(1,cur.RowCount)
''Log(hj)
cur2 = sql.ExecQuery("SELECT * FROM we")
For i = 0 To cur2.RowCount -1
ListView1.AddSingleLine(cur2.GetString("Question"))
Next
End Sub
Sub JobDone(job As HttpJob)
If job.Success = True Then
If job.JobName = "job" Then
Dim out As OutputStream
If File.Exists(File.DirInternal,"test.db") = True Then
File.Delete(File.DirInternal,"test.db")
End If
out = File.OpenOutput(File.DirInternal,"test.db",False)
File.Copy2(job.GetInputStream,out)
out.Close
Button1.Enabled = True
Else
Log(job.ErrorMessage)
End If
job.Release
End If
End Sub
سوال
Mahdi83 2
سلام
ببینید مشکل این سورس چیه که وقتی میخواد یه دیتابیس رو از سرور بگیره و با دیتابیس فعلی جایگزین کنه
#Region Project Attributes #ApplicationLabel: B4A Example #VersionCode: 1 #VersionName: 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: unspecified #CanInstallToExternalStorage: False #End Region #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 Dim cur,cur2 As Cursor 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 hj As Int Dim http As HttpJob Private Button1 As Button Private Label1 As Label Private ListView1 As ListView 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("L1") http.Initialize("job",Me) http.Download("http://b4a1test.ihweb.ir/test.db") If File.Exists(File.DirInternal,"test.db") = False Then File.Copy(File.DirAssets,"test.db",File.DirInternal,"test.db") End If If sql.IsInitialized = False Then sql.Initialize(File.DirInternal,"test.db",False) End If Button1.Text = "Show" Button1.Enabled = False End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub Button1_Click 'cur = sql.ExecQuery("SELECT id FROM we") ''hj = Rnd(1,cur.RowCount) ''Log(hj) cur2 = sql.ExecQuery("SELECT * FROM we") For i = 0 To cur2.RowCount -1 ListView1.AddSingleLine(cur2.GetString("Question")) Next End Sub Sub JobDone(job As HttpJob) If job.Success = True Then If job.JobName = "job" Then Dim out As OutputStream If File.Exists(File.DirInternal,"test.db") = True Then File.Delete(File.DirInternal,"test.db") End If out = File.OpenOutput(File.DirInternal,"test.db",False) File.Copy2(job.GetInputStream,out) out.Close Button1.Enabled = True Else Log(job.ErrorMessage) End If job.Release End If End Sub
لینک ارسال
به اشتراک گذاری در سایت های دیگر
4 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.