B4J Question SQL Server Help

Bachrock

Member
Licensed User
Longtime User
Hi, I would like to create a B4J project very similar to the DataCollection project which had the Android and Desktop clients. However I would like to do this in SQL Server instead of SQL Lite. I am not quite sure how to do this. I know I would have to put the connection string in and then point to the table. Is there any good example I can look at in order to do this? I think I need to use DBUtilies, but again I am kind of lost. So any direction would be greatly appreciated.
 

Bachrock

Member
Licensed User
Longtime User
Erel, I studied your SQL Tutorial and Connection Pool suggestions, however at this point I believe it is a little bit beyond my capabilities. If you or anyone comes across a clearer example of how to connect to a SQL Server Database including buiding the connection string, and inserting new data into a table I would love to see it. If not it will have to wait for a rainy day and I will give it another go.... Thanks
 
Upvote 0

fernando gibert

Member
Licensed User
Longtime User
You must prior add mysql-connector into region ( this sample uses easyphp sql )

#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#AdditionalJar: mysql-connector-java-5.0.8-bin
#End Region


Sub Process_Globals
Private MainForm As Form
Dim sql1 As SQL
Dim rs As ResultSet


Dim tableview1 As TableView
Private txt1 As TextField
Dim s As String
Dim lbl As Label
Private txt2 As TextField
txt1.Initialize("")
txt2.Initialize("")

End Sub
Sub AppStart (Form1 As Form, Args() As String)

MainForm = Form1
MainForm.Show

MainForm.RootPane.LoadLayout("main")

ejecuta
End Sub
Sub ejecuta




sql1.Initialize2("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/anom", "root", "")

rs=sql1.ExecQuery("SELECT * FROM xs")

Do While rs.nextrow

tableview1.SetColumns(Array As String("Myxs" , "Name"))


Dim row(2) As Object
row(0) = (rs.getstring("ga"))
row(1) = (rs.getstring("gb"))
format (row(0))
row(0)=s


tableview1.Items.Add(row)
Dim lbl As Label
lbl.Initialize("")
lbl.Text = row(1)
row(1) = lbl
Loop

End Sub
 
Upvote 0
Top