URLEncoding, WebClient, Access->SQLCe, SpecialFolders

S

Steve Podradchik

Hi,

In porting a desktop app to the CompactFramework, we're doing OK on
compatibility but we do wonder if folks have solutions for some of the
missing things we need:

1. We need to post data to a Web site in a URLEncoded fashion.
web.HTTPUtility seems missing. How do we do a URLEncode? This must be here
somewhere?

2. We need to upload files to a Web server. On the desktop version, we
used a modified version of some sample code in Help. The sample code uses
the WebClient class which is missing in CF. Ideas?

3. System.Environment.GetFolderPath is used on the desktop app to know
where to put user files
(GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) for example.
Any idea what we should use instead?

4. What's the easiest way to port an entire Access (.mdb) database to a
SQLCe file? I read the previous notes about InTheHand but our database will
be very, very large so I'd rather use SQLCe. Also, does anyone have
thoughts on relative file size and performance?

Thanks, Steve
 
G

Guest

Regarding #4

Is this a one time transfer of information or is this to be done on a regular basis by your users in the field? If its one time, then I would suggest dumping the tables to a flat file or a SQL script and then just running it in Query Analyzer

If its a day-to-day synch functionality, you should probably just let ActiveSync do the conversion from an MDB to a CDB. Having said that, depending on your budget and configuration there are 3rd party software suites that will accomplish this sort of functionality (iAnywhere, Synchrologic's Real Synch Server to name a couple), but they require administration overhead. Tell me a little bit about your user's environment

~~K
 
G

Guest

Regarding #2

This has always worked well for me. If all else fails, you can always open a socket and write the data in HTTP format manually

using System.Net
using System.IO
using System.Text

...

public string postUrl_data_type(string url,string data, string type


tr

System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
if (data == ""

return ""

url = "http://"+url
System.Text.ASCIIEncoding ac = new System.Text.ASCIIEncoding()
System.Text.UnicodeEncoding uni = new UnicodeEncoding()

HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(url)
wReq.Timeout = wReq.Timeout * 50
wReq.ProtocolVersion = HttpVersion.Version10
wReq.Method = "POST"
wReq.ContentType = type

byte [] buff = ac.GetBytes(data)
wReq.ContentLength = buff.Length
Stream outputstream = wReq.GetRequestStream()
outputstream.Write(buff,0,buff.Length);
outputstream.Close()

WebResponse wResponse = wReq.GetResponse()
Stream respStream = wResponse.GetResponseStream()
StreamReader reader = new StreamReader(respStream, ac)
String respHTML = reader.ReadToEnd()
wReq.Abort()
wResponse.Close()
return respHTML

catch (Exception err

System.Windows.Forms.Cursor.Current = Cursors.Default
throw err

return ""


~~K
 
S

Steve Podradchik

Basically a one-time thing. My company makes flight planning software for
pilots. We currently make a desktop version and used .Net specifically to
make PDA porting easier ... so we took reasonable care to write
CF-compatible code when time allowed. Flight planning involves relatively
(for a PDA) large databases. We have one Access DB that's about 50MB and
contains all the land, rivers, roads for North America and another of
roughly equal size that has the aviation-specific information such as
airports, airspace, etc. I assume we'll have to cut a lot of data to get
things to fit, of course.

Not sure I understand using the Query Analyzer in this context. First, our
data is in Access not SQL. Of course, we can easily Upsize it to SQL
Server. But then how to get it to SQLCe? You would think someone would
have a nice simple "point at an Access DB, out pops a SQLCe data file"
application.

Then, just to make things more interesting --- in the desktop version, we do
ship new versions of the airspace DB every 28 days (FAA cycle) but, instead
of shipping the whole new DB, we use XML DiffGrams to ship just the
differences and integrate on the fly. Unlike a typical business app, there
is no need for the end-user to update the data on the server -- it's a one
way, read-only trip.

Now ... as I write this ... looks like someone here is a little ahead of me.
Apparently, we already wrote the import app some time ago and just need to
update it to the shipping CF (yes, it was that long ago!) and our current
schema. I gather the idea, after posting the data to a SQL Server, is to
use a RemoteDataConnection to Pull the data to the CF "Import" app? That
sound about right? Still seems clunky.

Thanks, Steve
www.seattleavionics.com


Kevin Z Grey said:
Regarding #4:

Is this a one time transfer of information or is this to be done on a
regular basis by your users in the field? If its one time, then I would
suggest dumping the tables to a flat file or a SQL script and then just
running it in Query Analyzer.
If its a day-to-day synch functionality, you should probably just let
ActiveSync do the conversion from an MDB to a CDB. Having said that,
depending on your budget and configuration there are 3rd party software
suites that will accomplish this sort of functionality (iAnywhere,
Synchrologic's Real Synch Server to name a couple), but they require
administration overhead. Tell me a little bit about your user's
environment.
 
G

Guest

What I would do is dump the database to a flat file on your desktop, then use a utiltiy like UltraEdit (or write a small program or perl script) to take the rows and generate a list of SQL Statements. Once you have the SQL Statements, its just a matter of opening the script on the device in Query Analyzer and executing it to populate your database

If you believe you'll have to do it more than once, then I would write an app to handle it autonomously

Alternatively you could copy the MDB file to the device and have activesync convert it to a CDB file. Write an app that will open the CDB file and read the table data and write it out to an SDF. This is assuming the CDB file can fit on your device without any storage issues

~~K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top