G Gnappo jr Active Member Licensed User Longtime User Sep 22, 2017 #1 In Connect Android to MS SQL Server Tutorial: https://www.b4x.com/android/forum/threads/connect-android-to-ms-sql-server-tutorial.13166/ There is a very effective asp.net script, i would like to do the same thing in b4j, can i get help? Also for this part of ASP code: while (rdr.Read()) { Dictionary<string, object> d = new Dictionary<string, object>(rdr.FieldCount);for (int i =0;i < rdr.FieldCount;i++) { d[rdr.GetName(i)] = rdr.GetValue(i);} list.Add(d); } JavaScriptSerializer j = new JavaScriptSerializer(); Response.Write(j.Serialize(list.ToArray())); } Thanks to anyone
In Connect Android to MS SQL Server Tutorial: https://www.b4x.com/android/forum/threads/connect-android-to-ms-sql-server-tutorial.13166/ There is a very effective asp.net script, i would like to do the same thing in b4j, can i get help? Also for this part of ASP code: while (rdr.Read()) { Dictionary<string, object> d = new Dictionary<string, object>(rdr.FieldCount);for (int i =0;i < rdr.FieldCount;i++) { d[rdr.GetName(i)] = rdr.GetValue(i);} list.Add(d); } JavaScriptSerializer j = new JavaScriptSerializer(); Response.Write(j.Serialize(list.ToArray())); } Thanks to anyone
Erel B4X founder Staff member Licensed User Longtime User Sep 24, 2017 #2 A much more efficient and better implementation is available in jRDC2. Upvote 0
G Gnappo jr Active Member Licensed User Longtime User Sep 25, 2017 #3 Erel said: A much more efficient and better implementation is available in jRDC2. Click to expand... Thanks Erel, I will study jRDC2. For study purposes and to prove that the ASP server in the example can be done in B4J, you should convert this aspnet server code ... JavaScriptSerializer j = new JavaScriptSerializer(); Response.Write(j.Serialize(list.ToArray())); ... in B4J code. I'm stranded here: (B4J server) Sub Handle(req As ServletRequest, resp As ServletResponse) mreq = req mresp = resp Dim miasql As String, ser As B4XSerializator, lista As List miasql=mreq.GetParameter("query") lista=ExecuteMemoryTable(Main.sql1, miasql , Null, 0 ) resp.ContentType ="text/html" '???????????? resp.Write( ser.ConvertObjectToBytes(lista)) '??????????????? ' What is the correct code? End Sub This is the B4A client code that works well with asp server Sub JobDone (Job As HttpJob) If Job.Success Then Dim parser As JSONParser Dim response As String = Job.GetString parser.Initialize(response) Dim rows As List rows = parser.NextArray Select Case Job.JobName Case "Job0" 'work with result 'rows is a List. Each item is a Map with the columns names as keys and the db values as the values. For i = 0 To rows.Size - 1 Log("Rows #" & i) Dim m As Map m = rows.Get(i) TotPersone.Text=m.Get("TotPersone") Next ..... .... Upvote 0
Erel said: A much more efficient and better implementation is available in jRDC2. Click to expand... Thanks Erel, I will study jRDC2. For study purposes and to prove that the ASP server in the example can be done in B4J, you should convert this aspnet server code ... JavaScriptSerializer j = new JavaScriptSerializer(); Response.Write(j.Serialize(list.ToArray())); ... in B4J code. I'm stranded here: (B4J server) Sub Handle(req As ServletRequest, resp As ServletResponse) mreq = req mresp = resp Dim miasql As String, ser As B4XSerializator, lista As List miasql=mreq.GetParameter("query") lista=ExecuteMemoryTable(Main.sql1, miasql , Null, 0 ) resp.ContentType ="text/html" '???????????? resp.Write( ser.ConvertObjectToBytes(lista)) '??????????????? ' What is the correct code? End Sub This is the B4A client code that works well with asp server Sub JobDone (Job As HttpJob) If Job.Success Then Dim parser As JSONParser Dim response As String = Job.GetString parser.Initialize(response) Dim rows As List rows = parser.NextArray Select Case Job.JobName Case "Job0" 'work with result 'rows is a List. Each item is a Map with the columns names as keys and the db values as the values. For i = 0 To rows.Size - 1 Log("Rows #" & i) Dim m As Map m = rows.Get(i) TotPersone.Text=m.Get("TotPersone") Next ..... ....