Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

Connection with MSSQL and php

How can i connect my MSSQL database to an application? i have allready an IIS installed and i have a url with .php encoding and exporting data with json format. how can i show the results to an appery application?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Connection with MSSQL and php

Hello Stelios,

You should create REST service in appery.io and specify appropriate parameters: http://docs.appery.io/documentation/r...

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

Connection with MSSQL and php

Evgene, thank you very much for your quick reply.
I had created a REST service, using the url and i have a parameter "q"
when i set a value to this parameter (lets say, 1) in the test response, i get the desired result as json :)
Also i have set the table field in the "Response" tab (e.g. user_name)
The thing is.. i just want to make this user_name field come up to a label or text component :) i do bind the field and set the event to invoke the service at startApp but nothing happens :(
Is there anything that slipped my mind??

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Connection with MSSQL and php

Please specify what do you mean on event "AppStart"? Also please try using event "page show".

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

Connection with MSSQL and php

Forgive me, the event is "Load" on the startScreen component.
thats where I invoke my MSSSQL service. i have some screenshots that might help you a bit.

on this picture i have my url with the .php file (inside the php is just a select statement)
Image

the php takes this "q" as parameter (input)
Image

the database has these three fields. i created these automatically from the json response.
Image

here you can see the binding with a textfield from the form.
Image

BTW, my php has the following result when my parameter q=1
{"0":"ADMIN","USR_NAME":"ADMIN","1":"Administrator","USR_FULL_NAME":"Administrator","2":1,"ID":1}

So, when i set hardcoded the input q = 1, and start the test.. shouldn't the text field show me the word "Administrator"???
Am I missing something?

Thank you..

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Connection with MSSQL and php

Hi,

If you use your server, you would need to use Appery.io proxy for cross-domain requests:
http://docs.appery.io/documentation/s...
http://docs.appery.io/documentation/c...

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

Connection with MSSQL and php

Hi Katya,

Thank you very much for your reply.
As i understand correctly I just need a proxy service between the json parsing and the REST service. So i made one as you can see below:

Here i just created a proxy with a name
Image

Here, i added the two request parameters if I understand correctly (appery-rest with the guid and the appery-tranformation, both headers)
Image

When i test, I get the desired result as json (I remind you that the json export is coded inside the php file [json_encode])
Image

I also changed the settings of REST, Data Type from json to jsonp.
Is there anything else that is not done yet? Is there any problem with my export format?

Thank you

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Connection with MSSQL and php

Hello!

1) You don't need Proxy if you use JSON
2) Did you recieve response you expected from server? If you didn't, please check your servise response for example in postman and post it here.

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

Connection with MSSQL and php

Hi Maryana,

So, ok I uncheck the Proxy option.

I receive the expected response from server as you see in the last screenshot of my previous post. It is in json format and the field is USR_FULL_NAME : Administrator
Now, i have binded the this field with a label on my program as you see on the last screenshot on my first post.
When i test the program, shouldn't it show the word "Administrator" ? Instead, it says "Labgel1" :P Somehow the result of my SQL Service (REST) does not pass to the label :)

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Connection with MSSQL and php

Hello Stelios,

Have you called your service, for example before show your page?

Return to “Issues”