Get data from SQL Server

junaidahmed

Well-Known Member
Licensed User
Longtime User
i am new for developing application in basic4android,pls advise how to create webservice in server,awaiting for your replay
 
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
I dont't know how to create webservice,I want to display SQL server 2000 record in my android devices.please explain step by step procedure.Eagerly awaiting for your replay
 
Upvote 0

alfcen

Well-Known Member
Licensed User
Longtime User
Hello,

You need to write a PHP script and upload it to your server where the database resides.
The PHP script queries the database and returns a given result. The format of the result
is your choice, preferrably CSV, HTML or XML.

Use the HTTP library to address the URL of the PHP script on the server with query parameters, such as

B4X:
http://www.myserver.com/query.php?table=products&where=material&type=iron

The PHP script should then generate an sql query, something like

B4X:
SELECT from " . $table . " WHERE " . $material . " = iron"

The PHP script will then return all items that match the query in either of CSV, HTML or XML.

This data will then be received by the HTTP library in return to the URL request above
and need to be parsed appropriately to obtain the desired display for the Android.

Sorry, I can offer a mere rough guide, since such a project depends on too many individual details,
which only you know.

If in doubt about how to write in PHP/Sql, please try and get help from your friends or colleagues in your vicinity.
PHP/Sql issue lie beyond the scope of B4A support.
 
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
Error Connecting to Server

As per your opinion I have wrote a PHP script and upload it to our server and the format of the result is html format,the result works fine in the browser,but when execute the HttpRequest (from http Library) it shows an error

"Error Connecting to Server Java.net.unknownHostException : www.kharind.com"

My Code is :

Dim request As HttpRequest
Dim URL as String
URL = "http://www.kharind.com/experiment/Test.php"

request.InitializeGet(URL)
request.Timeout = 10000 'set timeout to 10 seconds
If HttpClient1.Execute(request, 1) = False Then Return

Please advise how to do this,Eagerly awating for your replay.
 
Upvote 0

gemasoft

Member
Licensed User
Longtime User
Sql Server Php

Here an example for access to php with odbc and apache.
First is important install the sql driver for php from microsoft site. After if the php extension is ok. you can test this code for retrieve a SQL SELECT statement.
 

Attachments

  • PHP_SQLSERVER.txt
    448 bytes · Views: 600
Last edited:
Upvote 0
Top