1. First, if IIS is not installed, install IIS first. XP is installed with an installation disk.
If the environment is Windows 2008 iis7, the following error message will appear during installation (IIS 6.0) backward compatibility components. The solution is to install IIS 6 management compatibility first, see:
Http://support.microsoft.com/default.aspx? SCID = KB; en-US; 955966 & SD = RSS & spid = 2855
2. Download and install SQL Server compact 3.5 Service Pack 1 server tools.
Yes
Http://www.microsoft.com/downloads/details.aspx? Displaylang = en & familyid = fa751db3-7685-471b-ac31-f1b150422462 # filelist
3. Configure SQL Server compact 3.5 Service Pack 1 server tools.
Run configure web Synchronization Wizard (configure web Synchronization Wizard) under SQL Server compact 3.5 in the Start Menu program ).
- Select "SQL Server compact" for the subscription type ".
- Select "Create a new virtual directory ".
- Select copy SQL Server proxy to directory ".
- In the client authentication wizard, select "authenticate the client, enter the user name and password required ".
On the authentication method, select "basic verification ". Note: If you configure the IIS server proxy to use basic or integrated authentication, you must specify the internetlogin and internetpassword attributes when using the RDA object.
4. Install sqlserver compact 3.5 on a mobile device.
Manual installation and automatic installation.
Automatic installation:
If you use Microsoft Visual Studio to generate a file that uses Microsoft SQL Server compact 3.5 (SQL Server compact 3.5) and. when you deploy the application on the device for the first time, the SQL Server compact 3.5 engine is automatically installed on the device.
Manual installation:
You can manually copy the. cab file to the device and Install SQL Server compact 3.5 on the device. If you are generating a local application, you must manually copy the. cab file.
Please refer to the following article: how to select the correct SQL Server compact installation package
5. Create the database mymoney on the SQL Server server for testing, which contains a table record. The field information is:
Id int notnull PK to use RDA, the primary key must be set for the table
Action varchar (50) notnull
Cost money notnull
6. Programming implementation RDA.
Use vs2008 to write a mobile device application. The following code is implemented in form. The following code runs successfully on ipaq.
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. Data. sqlserverce;
Namespace smartdeviceproject1
{
Public partial class form1: Form
{
// N28201 in datasource is the host name of the IIS server and SQL Server.
Private string scon = @ "provider = sqloledb; Data Source = n28201 ;"
+ @ "Initial catalog = mymoney ;"
+ @ "Integrated Security = sspi; persist Security info = false ";
// Test is the virtual directory name.
Private string interneturl = @ "http: // n28201/test/sqlcesa35.dll ";
Private string localconnectionstring = @ "Data Source =/My Documents/mymoney. SDF ";
// IIS uses basic authentication. You must provide the following user name and password for Windows.
Private string internetlogin = "sa ";
Private string internetpassword = "sa ";
Public form1 ()
{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
{
// First, ensure you have an empty local SQL ce database.
If (system. Io. file. exists (@ "/My Documents/mymoney. SDF "))
{
System. Io. file. Delete (@ "/My Documents/mymoney. SDF ");
}
// Create new database.
Sqlceengine Eng = new sqlceengine (localconnectionstring );
Eng. createdatabase ();
Using (sqlceremotedataaccess RDA = new sqlceremotedataaccess ())
{
RDA. interneturl = This. interneturl;
RDA. internetlogin = This. internetlogin;
RDA. internetpassword = This. internetpassword;
RDA. localconnectionstring = localconnectionstring;
Try
{
RDA. Pull ("record", "select * from record ",
Scon, rdatrackoption. trackingon, "rdarecorderrors ");
}
Catch (sqlceexception sqlceex)
{
MessageBox. Show (sqlceex. tostring ());
Return;
}
Finally
{
RDA. Dispose ();
}
MessageBox. Show ("RDA pull done! ");
}
}
Private void button2_click (Object sender, eventargs E)
{
Using (sqlceremotedataaccess RDA = new sqlceremotedataaccess ())
{
RDA. interneturl = This. interneturl;
RDA. internetlogin = This. internetlogin;
RDA. internetpassword = This. internetpassword;
RDA. localconnectionstring = localconnectionstring;
Try
{
RDA. Push ("record", this. scon );
}
Catch (sqlceexception sqlceex)
{
MessageBox. Show (sqlceex. tostring ());
Return;
}
Finally
{
RDA. Dispose ();
}
}
MessageBox. Show ("RDA push done! ");
}
Private void button4_click (Object sender, eventargs E)
{
Using (sqlceremotedataaccess RDA = new sqlceremotedataaccess ())
{
RDA. interneturl = This. interneturl;
RDA. internetlogin = This. internetlogin;
RDA. internetpassword = This. internetpassword;
RDA. localconnectionstring = localconnectionstring;
Try
{
RDA. submitsql ("Update record set cost = 888 where id = 1", this. scon );
}
Catch (sqlceexception sqlceex)
{
MessageBox. Show (sqlceex. tostring ());
Return;
}
Finally
{
RDA. Dispose ();
}
}
MessageBox. Show ("RDA submitsql done! ");
}
Private void button3_click (Object sender, eventargs E)
{
Application. Exit ();
}
}
}
6. Install activesync4.5 on XP.
7. Connect the mobile device to the XP host using USB, and release the project to the mobile device using vs2008. The operation is successful.
After pull runs successfully, two tables rdarecorderrors and record are created in mymoney. SDF of the mobile device.