CSharpCoder

I've been doing some reading on the push and pulling of data from SQL to SQL ce (mobile) using RDA. I have an existing web service that is connecting the source SQL server database and returning a dataset, is it possible to use this web service and do the 'pull' and populate the SQL ce on the mobile device If so can someone point me to some examples of this being done



Re: Smart Devices VB and C# Projects use web service for pull?

AlexY

Just download the dataset and use SqlCeAdapter to update the local database.





Re: Smart Devices VB and C# Projects use web service for pull?

IGotyourdotnet

do you have an example of this I'm totally new to the mobile development thing and learning as I go pretty much



Re: Smart Devices VB and C# Projects use web service for pull?

AlexY

Something like that:


SqlCeConnection conn = new SqlCeConnection(dataSource);
conn.Open();
string sql = String.Format("select * from {0}", tableName);
SqlCeDataAdapter adapter = new SqlCeDataAdapter(sql, conn);
SqlCeCommandBuilder commandBuilder = new SqlCeCommandBuilder(adapter);
adapter.InsertCommand = commandBuilder.GetInsertCommand();

adapter.UpdateCommand = commandBuilder.GetUpdateCommand();

adapter.Update(mobileDataSet, tableName);
adapter.Dispose();
conn.Close();





Re: Smart Devices VB and C# Projects use web service for pull?

IGotyourdotnet

" SqlCeConnection conn = new SqlCeConnection(dataSource);"

I'm using a dataset being returned from my main database, would that be the 'datasource' for here

on this:

"string sql = String.Format("select * from {0}", tableName)"

what is {0}, and what the table name be My mobile db table, or my dataset table such as ds.Table[0]






Re: Smart Devices VB and C# Projects use web service for pull?

Zero Dai - MSFT

Dear friend,

1. "SqlCeConnection conn = new SqlCeConnection(dataSource);"

No, here "dataSource" means a connection string for your local Sql mobile database, since the instance here is type of SqlCeConnection.

2. "string sql = String.Format("select * from {0}", tableName)"

Here, {0} is just a token for the second parameter. After executing this statement, the content of sql is "select * from <tableName>". And Yes, the tableName is your mobile db table.

Here has a MSDN document that may help you:

Step by Step: Developing a SQL Mobile Application with Visual Studio 2005 and SQL Server 2005

http://msdn2.microsoft.com/en-us/library/aa454892.aspx

Thanks!

Zero Dai - MSFT






Re: Smart Devices VB and C# Projects use web service for pull?

IGotyourdotnet

I don't want to create the database everytime. I want to use the existing database on the handheld and not delete and recreate it