Pocket PC SQL CE problems
I am really new to the .NET, C#, CE world and am working on a project with some pressing deadlines. Please bear with me. I've been having a few problems with the namespaces, let alone pulling the data.
For some reason the namespaces,
using System.Data.SqlServerCe;
using System.Data.SqlCeEngine;
using System.Data.SqlCeEngine.SqlCeRemoteDataAccess;
are not being identified during the build. I looked up the references and SqlServerCe is already present inthe references. Is there anything else I need to do to remove this error? I am not using SqlServerCe anywhere in the code but I was wondering about the reason for the error.
I have searched the desktop for SqlCeEngine.dll and SqlCeRemoteDataAccess.dll but was unable to locate them. I have installed Microsoft Visual Studio .Net Professional 2003, Microsoft Framework 1.1, Microsoft Embedded Visual tools, Microsoft Pocket PC 2003 SDK, Microsoft SQL Server 2000 and Microsoft SQL Server CE 2.0. Is there anything I need to install to get these?
My second question:
I am lil confused about the way things should be run. I need the final application (of which the following code is the starting point) running in a Pocket PC 2003 environment. My understanding is that I need to build and release the application into the Pocket PC 2003 environment and then run the application from there for it to pull data from the SQL Server 2000 db, which resides on the desktop. Please let me know if I have it wrong.
Any help will be greatly appreciated.
My code follows:
Form1:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.ComponentModel;
using System.Data.SqlServerCe;
using System.Data.SqlCeEngine;
using System.Data.SqlCeEngine.SqlCeRemoteDataAccess;
namespace PullData
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.button1 = new System.Windows.Forms.Button();
this.button1.Location = new System.Drawing.Point(88, 64);
this.button1.Text = "Pull Data";
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Controls.Add(this.button1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
}
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
string localDatabase = @"\EA.sdf";
string localConnectionString = "Data Source=" + localDatabase;
string remoteConnectionString = @"Provider=sqloledb;" + "Data Source=(local);Initial Catalog=EA;" + "Integrated Security=SSPI;";
string[] tables = new string[] { "Table1", "Table2", "Table3", "Table4", "Table5"};
if(File.Exists(localDatabase))
File.Delete(localDatabase);
SqlCeEngine engine = new SqlCeEngine(localConnectionString);
engine.CreateDatabase();
SqlCeRemoteDataAccess rda = new SqlCeRemoteDataAccess();
rda.InternetUrl = "http://ABHI/sqlce/sscesa20.dll";
rda.LocalConnectionString = localConnectionString;
foreach (string table in tables)
{
try
{
rda.Pull(table, "SELECT * FROM [" + table + "]", remoteConnectionString, RdaTrackOption.TrackingOffWithIndexes, "ErrorTable");
}
catch (SqlCeException ex)
{
//MessageBox.Show(ex.Message);
showErrors(ex);
}
}
}
catch (Exception excp)
{
MessageBox.Show("Exception: " + excp.Message);
MessageBox.Show("Base Exception: " + excp.GetBaseException().Message);
}
Form2 form2 = new Form2();
form2.show();
}
}
}
Form2 would work around with the data.
Abhi.

