silverlight 3 使用ADO.NET SERVICE 定期更新数据

keiven8 2010-02-17 11:09:02
//在做更新数据时遇到麻烦,查看资料,但似乎所有的资料都是结合了dataGrid 进行数据更新的。请高手们帮帮忙!感激不尽了!分不多了,大家帮帮忙!
//silverlight 3 使用ADO.NET SERVICE 定期更新数据

void timer_autoSave_Tick(object sender, EventArgs e)
{
if (userState.userId > 0)
{
// 自动保存用户状态到数据库
var query = from userInfo in proxy.userTable
where userInfo.userId == userState.userId
select userInfo;

try
{
MessageBox.Show("开始执行异步处理……");

//在这里我如何更新 userTable 下的 字段如 userScore 的值为 userScore+=100;

}
catch (DataServiceRequestException ex)
{
MessageBox.Show("发生异常1:"+ex.ToString());
}
}
}

void onUpdateCompleted(IAsyncResult result)
{
try
{
proxy.EndSaveChanges(result);
MessageBox.Show("执行成功!"+result.ToString());
}
catch (DataServiceRequestException ex)
{
MessageBox.Show("发生异常2:"+ex.Response.ToString());
}

}
...全文
158 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
heifengxia 2010-04-10
  • 打赏
  • 举报
回复
学习!
jv9 2010-02-20
  • 打赏
  • 举报
回复
如果你使用RIA Service + LINQ,可以在定时器中定时调用更新数据库的方法。

try
{
MessageBox.Show("开始执行异步处理……");

//RIA Service在这里,调用,需要在服务器端建立domain source
//也可以使用WCF Service
}
catch (DataServiceRequestException ex)
{
MessageBox.Show("发生异常1:"+ex.ToString());
}
SeekVerity 2010-02-19
  • 打赏
  • 举报
回复
直接更新数据库不可能,你在那个地方可以异步调用一个webservice来更新数据库
keiven8 2010-02-18
  • 打赏
  • 举报
回复
timer_autoSave_Tick 就是一个Timer呀。是在SILVERLIGHT 客户端 定期保存用户的状态。比如游戏过程中,定期保存用户的游戏积分等。
jv9 2010-02-18
  • 打赏
  • 举报
回复
定期更新数据是什么意思?是想让数据库自动更新对么?从客户端自动更新,就需要使用Timer,数据库里可以使用Trigger
Pro ADO.NET Data Services: Working with RESTful Data Paperback: 336 pages Publisher: Apress; 1 edition (December 2, 2008) Language: English ISBN-10: 143021614X ISBN-13: 978-1430216148 Format: PDF You can buy this book: Amazon.com Description: Pro ADO.NET Data Services: Working with RESTful Data is aimed at developers interested in taking advantage of the new REST–style data services that ADO.NET Data Services (formerly code–named Astoria) provides. The book shows how to incorporate ADO.NET Data Services into a wide range of common environments including BizTalk, AJAX and Silverlight client applications. The material is intended for professional developers who are comfortable with the .NET 3.5 Framework but are coming to ADO.NET Data Services for the first time and want to understand how to integrate it into their own applications and enterprise solutions. The book is packed full with extensive real–world solutions and exercises, ensuring you walk away with a deep understanding of how to use ADO.NET Data Services to your best advantage. What you’ll learn Implement software solutions using ADO.NET Data Services within a variety of enterprise–level environments. Integrate ADO.NET Data Services into enterprise applications using BizTalk Server. Take advantage of ADO.NET Data Services in standard and AJAX/Silverlight–enabled ASP.NET applications, as well as traditional .NET applications. Understand when to apply traditional SOAP programming methods vs. REST–style programming to achieve the best possible results. Incorporate ADO.NET Data Services into the latest Microsoft technologies in the cleanest possible way. Understand cloud computing from a business respective and where ADO.NET Data Services fits within this.
Silverlight 2系列(35):升级Silverlight 2 Beta 1应用程序到Beta 2 Silverlight 2系列(34):使用Silverlight Streaming托管Silverlight应用程序 Silverlight 2系列(33):Silverlight 2应用Web Service两例 Silverlight 2系列文章 Silverlight 2系列(32):图形图像综合实例—“功夫之王”剧照播放 Silverlight 2系列(31):图形图像综合实例—实现水中倒影效果 Silverlight 2系列(30):使用Transform实现更炫的效果(下) Silverlight 2系列(29):使用Transform实现更炫的效果(上) Silverlight 2系列(28):图片处理 Silverlight 2系列(27):使用Brush进行填充 Silverlight 2系列(26):基本图形 Silverlight 2系列(25):综合实例之Live Search Silverlight 2系列(24):与浏览器交互相关辅助方法 Silverlight 2系列(23):Silverlight与HTML混合之无窗口模式 Silverlight 2系列(22):在Silverlight中如何用JavaScript调用.NET代码 Silverlight 2系列(21):如何在Silverlight中调用JavaScript Silverlight 2系列(20):如何在Silverlight中与HTML DOM交互(下) Silverlight 2系列(19):如何在Silverlight中与HTML DOM交互(上) Silverlight 2系列(18):综合实例之RSS阅读器 Silverlight 2系列(17):数据与通信之ADO.NET Data Services Silverlight 2系列(16):数据与通信之JSON Silverlight 2系列(15):数据与通信之ASMX Silverlight 2系列(14):数据与通信之WCF Silverlight 2系列(13):数据与通信之WebRequest Silverlight 2系列(12):数据与通信之WebClient Silverlight 2系列(11):数据绑定 Silverlight 2系列(10):使用用户控件 Silverlight 2系列(9):使用控件模板 Silverlight 2系列(8):使用样式封装控件观感 Silverlight 2系列(7):全屏模式支持 Silverlight 2系列(6):键盘事件处理 Silverlight 2系列(5):实现简单的拖放功能 Silverlight 2系列(4):鼠标事件处理 Silverlight 2系列(3):界面布局 Silverlight 2系列(2):基本控件 Silverlight 2系列(1):创建一个基本的Silverlight应用

8,756

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧