Android Question how can i fix it?

kotukedi

New Member
Licensed User
Longtime User
Sub Globals
Dim eText As EditText
Dim Button1 As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
Dim db As MSSQL

Dim L As List
Dim hs As HorizontalScrollView
Dim vs As ScrollView


' If eText.Text=" " Then
' Msgbox("değer girmediniz", "Uyarı")
' Return
' End If
'

db.setDatabase("192.168.1.100","xyz","sa","sapass")
L = db.Query("Select CARI_ISIM,VERGI_DAIRESI,CARI_IL from TBLCASABIT where CARI_IL= 'eText.text' ")
If L.IsInitialized=False Then
Msgbox("Records Not Found","Warning")
Return
End If

Dim row As List,cols As Int ,rows As Int
rows = L.Size
row = L.Get(0) 'Header row
cols = row.Size

hs.Initialize(cols*150dip,0)
Activity.AddView(hs,0,0,100%x,100%y)

vs.Initialize(rows*30dip)
hs.Panel.AddView(vs,0,30dip,cols*150dip,100%y-30dip)

'CREATE HEADER LABELS
For j=0 To cols-1
hs.Panel.AddView(LabelCreate(row.Get(j),Colors.DarkGray,Colors.White) _
,j*150dip _
,0 _
,149dip _
,29dip)
Next

'CREATE RECORD LABELS
For i=1 To L.Size-1
row = L.Get(i)
For j=0 To cols-1
vs.Panel.AddView( LabelCreate(row.Get(j),Colors.LightGray,Colors.Black) _
,j*150dip _
,i*30dip-30dip _
,149dip _
,29dip)
Next
Next

End Sub



Sub LabelCreate(str As String,backcolor As Int,textcolor As Int) As Label
Dim t As Label
t.Initialize(0)
t.text=" " & str
t.color=backcolor
t.textcolor=textcolor
t.Gravity = Gravity.CENTER_VERTICAL
Return t
End Sub


i painted the problem with pink . what can i write there to get datas from mssql database. thanx for your help
 

KMatle

Expert
Licensed User
Longtime User
Please use code tags

You can build the query string with the paramaters like this:

B4X:
DIM q as string
q = "Select CARI_ISIM,VERGI_DAIRESI,CARI_IL from TBLCASABIT where CARI_IL='" & eText.text &"'"
L = db.Query(q)
...

The pink part doesn't replace the name of the edittext, so it compares the literal "eText.text" which can't be found in the table.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…