You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, download files, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact us.
I need a little bit of help on Windows Mobile 6 platform.
I am developing a database driven application using C# and SQL Server CE (Visual Studion 2005, .NET Framework CE 2.0 SP1). This application will be using the Remote Data Access concept. I seem to be able to pull data from the database server, but the device (PDA) stops responding when I try to enter a new record in the local database (.sdf). I can't seem to find a problem in logic or the code. Hope you guys can help. I have pasted the code at the end of this thread.
regards,
Shanker
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlServerCe;
using System.IO;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace RDA
{
public partial class MainForm : Form
{
string rdaOledbCon = @"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=MobileUser;Initial Catalog=WinMobile6;Data Source=192.168.1.107;Password=123456";
string rdaURL = @"http://192.168.1.16/SqlMobile/sqlcesa30.dll";
string localDeviceCon = @"Data Source=\My Documents\RdaDB.sdf";
public MainForm()
{
InitializeComponent();
}
private void mnuRDAPull_Click(object sender, EventArgs e)
{
RDAPull();
}
private void RDAPull()
{
try
{
if (File.Exists("\\My Documents\\RdaDB.sdf"))
File.Delete("\\My Documents\\RdaDB.sdf");
SqlCeEngine ceEngine = new SqlCeEngine();
ceEngine.LocalConnectionString = localDeviceCon;
ceEngine.CreateDatabase();
ceEngine.Dispose();
SqlCeRemoteDataAccess rda = null;
rda = new SqlCeRemoteDataAccess(rdaURL, localDeviceCon);
rda.InternetUrl = rdaURL;
rda.LocalConnectionString = localDeviceCon;
rda.Pull("Customers", "Select * from Customers", rdaOledbCon, RdaTrackOption.TrackingOn);
rda.Pull("CustTest", "Select * from CustTest", rdaOledbCon, RdaTrackOption.TrackingOn);
rda.Dispose();
MessageBox.Show("Done!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void mnuAddRow_Click(object sender, EventArgs e)
{
try
{
SqlCeConnection connection = new SqlCeConnection(localDeviceCon);
connection.Open();
string guid = Guid.NewGuid().ToString();
string sql = "Insert into Customers(FirstName, LastName, State, ID) values('Sreejith', 'V.R.', 'Kerala', '" + guid + "')";
SqlCeCommand command = new SqlCeCommand(sql, connection);
command.ExecuteNonQuery();
command.Dispose();
connection.Dispose();
MessageBox.Show("Done!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void mnuRDAPush_Click(object sender, EventArgs e)
{
try
{
SqlCeRemoteDataAccess rda = null;
rda = new SqlCeRemoteDataAccess(rdaURL, localDeviceCon);
rda.Push("Customers", rdaOledbCon, RdaBatchOption.BatchingOn);
rda.Dispose();
MessageBox.Show("Done!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void mnuPopulateGrid_Click(object sender, EventArgs e)
{
SqlCeConnection connection = new SqlCeConnection(localDeviceCon);
connection.Open();
DataSet ds = new DataSet();
SqlCeDataAdapter adpt = new SqlCeDataAdapter("Select * from Customers", connection);
adpt.Fill(ds,"Customers");
connection.Dispose();
grdRDA.DataSource = ds.Tables["Customers"];
}
}
}