Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 151

Ed Goodall
Fusion Technology
Profile
Posts: 422
Reg: Oct 01, 2011
Wiltshire, UK
12,320
09/03/14 07:24 AM (9 years ago)

Pull information from MSSQL Database

Hi Much like @Angry Ninja's Instant Database App, I need to create an app that queries my MSSQL database and shows information attached to it. For example, on one screen, I type 385, on another screen it returns all the information in the same row for 385 pulled from MSSQL. Any ideas on how this is possible? I could consider MySQL instead but would prefer MSSQL. Thanks Ed
 
sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
like
09/03/14 03:49 PM (9 years ago)
Remote, right? If it has a php script you just get the results, pop them into an array that is structured right and do a json encode and echo it out. I've written a script that queries a phpLD database and spits out the json for Niraj's cubbyholes complete with loadScreenObject and more dataURLs. check out tonz.info/json_listing.php?cat=64&place=1 catch me on chat or skype sarah.king if you want to run through the details or post some code here if you want it checked. I saw a comment in another thread about how white space around an array breaks the json. It hasn't been my experience so lay your code out anyway that makes sense. I like arrays because var_dump makes them super-readable and then json_encode does the rest.
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
09/03/14 06:58 PM (9 years ago)
I'd love to see any database info pasted here. DB usage is something I'd love to get working, but have yet to find enough to hack together to get it to work. (Anything Catalogue like would have so many uses!)
 
sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
like
09/03/14 08:47 PM (9 years ago)
Lots of it depends on the source and the json structure you need output. The link above is generated from this: https://onedrive.live.com/redir?resid=71DA6DFBE22FBAB0!16559&authkey=!AG3da5EQdWJBtTc&ithint=file%2cphp I'm not convinced the top part of the array gets used and it outputs a bunch of shop locations. If you have any questions about it fire away. FWIW when I get some breathing space I'm going to do a plugin for WordPress to output as BT style json
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
09/03/14 09:32 PM (9 years ago)
Thanks for sharing that PHP code, Sarah! A custom post types and custom fields plugin with WordPress that outputs Buzztouch-dialect of JSON would be awesome! I can work with you on the iOS side of things. -- Niraj
 
Ed Goodall
Fusion Technology
Profile
Posts: 422
Reg: Oct 01, 2011
Wiltshire, UK
12,320
like
09/04/14 07:43 AM (9 years ago)
Basically, I need to enable customers to type in a number plate and then it goes back to my SQL database and on another screen, shows whether fields in the table are equal to YES and NO... possible? Ed
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
09/04/14 08:52 AM (9 years ago)
Absolutely possible! Just need to write the PHP or ASP or HTML code to: 1. Accept and clean the number of the plate 2. Query the database with that cleaned number 3. In JSON format, send a response back to mobile app with a status code (found it, did not find it) and other related info In the mobile app, you can use a HTML or CustomURL plugin that has the starting form. Or you can use Chris1 Webform or Ultimate Dcreen Creator plugins. Either way, the mobile screens would be generated by your Server as HTML. Alternatively, you can use this opportunity to make a custom plugin and learn loads. -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
09/04/14 09:14 AM (9 years ago)
Take a look at Mark's classic guide on querying a database for map points and then sending the results back to the mobile app in JSON format. It's in the How-ato section of this web site. https://www.buzztouch.com/resources/ -- Niraj Posting a Device's Current Location to a Database This guide details the necessary steps to gather information about the devices location, log them to a backend database, then output the results on a map. This technique can be very very useful and flexible for location aware apps. Submitted by: GoNorthWest https://www.buzztouch.com/files/howtos/Posting_Current_Location_to_a_Database_v1.0.pdf
 
Ed Goodall
Fusion Technology
Profile
Posts: 422
Reg: Oct 01, 2011
Wiltshire, UK
12,320
like
09/04/14 10:04 AM (9 years ago)
So, Niraj, would you be able to help me with this over BT Chat (Just need to write the PHP or ASP or HTML code to: 1. Accept and clean the number of the plate 2. Query the database with that cleaned number 3. In JSON format, send a response back to mobile app with a status code (found it, did not find it) and other related info ) ? Thanks Ed
 
Ed Goodall
Fusion Technology
Profile
Posts: 422
Reg: Oct 01, 2011
Wiltshire, UK
12,320
like
09/04/14 10:44 AM (9 years ago)
Oh and Niraj, that PDF is for MySQL, I am hoping to use MS SQL
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
09/04/14 11:57 AM (9 years ago)
Ed -- I don't know how to use MS SQL for the DB connection and query. It should be similar to MySQL. Let's try a few things on the chat ... Now where is CakeBit's app for the chat? :-) Mark's PDF is still applicable, just swap in MS SQL instead of MySQL. -- Niraj
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.