Please provide me sample code for tableview for below RDC URL
Dim job As HttpJob
Dim StrURLPath as String
Dim Query as String
StrURLPath = "http://103.76.188.138:85/"
Query = "Select DeptName Dept,celltype Sections,empname,total from Mis.Dbo.Vw_StaffSalary Order by DeptName,CellType,EmpCode "
Dim job As HttpJob
Dim StrURLPath as String
Dim Query as String
StrURLPath = "http://103.76.188.138:85/"
Query = "Select DeptName Dept,celltype Sections,empname,total from Mis.Dbo.Vw_StaffSalary Order by DeptName,CellType,EmpCode "
job.Initialize("Job1", Me)
job.PostString(StrURLPath & "Android/FrmRemoteSQL.aspx",Query)
FrmRemoteSQL is an ".aspx file",Please check below code
B4X:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.IO;
using System.Text;
using System;
namespace Android
{
public partial class FrmRemoteSQL : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection cn = new SqlConnection("Server=Arindsql;Database=Mis; User Id=sa; password=Pass@123")) //change as needed
{
using (StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8))
{
Response.ContentType = "text/plain";
string c;
c = Request.QueryString["query"]; //for debugging with the browser
//you can set the query by adding the query parameter For ex: http://127.0.0.1/test.aspx?query=select * from table1
if (c == null)
c = sr.ReadToEnd();
try
{
SqlCommand cmd = new SqlCommand(c, cn);
cn.Open();
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
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()));
}
catch (Exception E)
{
Response.TrySkipIisCustomErrors = true;
Response.StatusCode = 500;
Response.Write("Error occurred. Query=" + c + "\n");
Response.Write(e.ToString());
}
Response.End();
}
}
}
}
}