Sub Globals
Dim mh1 As MysqlHandler
Dim rs1 As ResultSet
Dim sv1 As ScrollView
Dim lv1 As ListView
Dim hsv1 As HorizontalScrollView
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("Layout1")
mh1.Initialize("host","dbname","user","pass")
If mh1.isConnected = False Then
Msgbox(mh1.SQLError, "Connection Error:")
Return
End If
' rs1 = mh1.Query("INSERT INTO `dbname`.`dbtable` (`C1`, `C2`, `C3`, `C4`) VALUES ('4', '4', '4', '4')")
rs1 = mh1.Query("select * from dbtable")
If rs1.IsInitialized = False Then
Msgbox("ResultSet is empty" & CRLF & mh1.SQLError, "Warning")
Return
End If
hsv1.Initialize(rs1.ColumnCount * 150dip,0)
Activity.AddView(hsv1,0,0,100%x,100%y)
sv1.Initialize(rs1.RowCount * 30dip)
hsv1.Panel.AddView(sv1,0,0,rs1.ColumnCount*150dip,100%y)
Dim l As Label
For i=0 To rs1.RowCount - 1
rs1.Position = i
For j=0 To rs1.ColumnCount - 1
l.Initialize("label" & j)
l.Text = rs1.GetString(j)
l.TextColor = Colors.Black
l.Color = Colors.White
sv1.Panel.AddView(l,j*150dip,i*30dip,149dip,29dip)
Next
Next
mh1.Close
End Sub