Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, bit new to this game but im wondering how or what the process is to link my database to a button on my app? the user should type a reference number, and be brought there quote from our database. any idea's would be greatly appreciated
Posted

1 solution

Not sure how much help I can be, I'm very new to mobile app development myself. However, I recently did a proof-of-concept application very similar to what you are trying to do. We wanted to allow users to access company data on our data base from mobile devices. The user enters part of a name, we return a list of companies containing the search string in a list box. They then click on one of them and we return some general information on the selected company.

The general approach I used was to put all the data base access in a Windows Communication Foundation (WCF) Web Service, and let the web service do all the heavy lifting. The mobile app then calls the two functions hosted by the web service also using WCF.

If you are new to WCF web services, try the tutorial at http://msdn.microsoft.com/en-us/library/ms734712.aspx[^].

I implemented the web service as a self hosting application, but you can also host it using IIS. The tutorial does it as a console application, but once I had that working, I then did it as a Windows Service using the Visual Studio service application template.

Once you have the web service running, you then need to generate some proxy code for your Windows Phone 7 client. This is done by running the Silverlight 3 service utility program located at c:\Program Files (x86)\Microsoft SDK's\Silverlight\v3.0\tools. The name of the utility is SlSvcUtil.exe.

The command line will look something like this:
SlSvcUtil /language:cs (or vb) /out:MyProxy.cs (or vb) http://localhost:port/ServiceName/Service


You then add MyProxy.cs and ServiceReference.clientconfig, both generated by the utility, to your project.

The proxy will contain code to call the web service functions, however, Silverlight WCF only supports aysnch functions. So, if your web service has a function named GetQuote, your proxy code will have a function named GetQuoteAsynch. You then need to add an event handler for the GetQuoteCompleted event. The results of the web service call will be returned in GetQuoteCompetedEventArgs.Result.

The call of the web service function can be put in the button clicked event handler, which sounds like what you want to do.

I have no idea if this is the best way to do what you want, but in my case, I needed to access an Oracle data base and I have no idea how to go about installing the Oracle client software on a mobile device. Since our system is web services based anyhow, this was a good approach for me.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900