Android Question Connect To MS SQL SERVER by okhttputils2

MohammadNew

Active Member
Licensed User
Longtime User
Hello everyone and specially Erel ,

this is my example for connect to MS SQL SERVER

please check and tell me what I do . Thanks
 

Attachments

  • okhttputils2.zip
    9.3 KB · Views: 210

MohammadNew

Active Member
Licensed User
Longtime User
please Erel do it ,, I have many examples but all did not valid.

just example do it for me and any person who needs it.
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
one of example when I run it give me error = internal server

this logs>

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Error occurred. Query=
System.InvalidOperationException: ExecuteReader: CommandText property has not been initialized

   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)

   at ASP.test1_aspx.Page_Load(Object sender, EventArgs ec)

this is my code

B4X:
Sub Process_Globals
 
Private quality= "quality" As String
End Sub

Sub Globals  
    Private ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)  
    Activity.LoadLayout("1")

    ListView1.SetLayout(0,30dip,100%x,100%y-30dip)
    fetchdata
End Sub

Sub fetchdata
    ProgressDialogShow("Fetching list of works")
    ExecuteRemoteQuery("http://hreeef-001-site1.ctempurl.com/test1.aspx", quality)  
End Sub

Sub ExecuteRemoteQuery(Query As String, jobname As String)
    Dim job As HttpJob
 
    job.Initialize(jobname, Me)
    job.PostString("http://hreeef-001-site1.ctempurl.com/test1.aspx", "SELECT id,fname FROM tbl1")
End Sub

Sub JobDone(Job As HttpJob)     
    ProgressDialogHide
    If Job.Success Then
    Dim res As String
        res = Job.GetString
        Log("Response from server: " & res)
        Dim parser As JSONParser
        parser.Initialize(res)
        Dim rows As List
        rows = parser.NextArray
      
        For i = 0 To rows.Size - 1
            Log("Rows #" & i)
            Dim m As Map
            m = rows.Get(i)
            ListView1.AddTwoLines(m.Get("id"),m.Get("fname"))
            Log("col1=" & m.Get("id")) 'log the values of col1 and col2
            Log("col2=" & m.Get("fname"))
        Next
 
    Else
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
this another example >

please anybody can help me I thank you so much.
 

Attachments

  • SqlServer.zip
    76.9 KB · Views: 248
Upvote 0
Top