如何创建windows c#应用程序以在线和离线工作 [英] How to Create windows c# application to work online and offline

查看:96
本文介绍了如何创建windows c#应用程序以在线和离线工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows应用程序。客户希望它在线工作(如果有互联网连接)和离线(如果没有互联网连接)。在线数据库应该更新的离线数据(如果有互联网连接)我该怎么做。

我正在使用c#和SQL 2008R2请帮帮我。对我来说非常紧急..

解决方案




只需将数据库保存在服务器中即可。使用本地数据库和您想要的东西开发客户端应用程序。以下是参考资料。



1.检查互联网连接 - 测试互联网连接



2.服务器中部署的数据库的连接字符串,

< pre lang =cs>数据源= ipadress\SQLEXPRESS;网络库= DBMSSOCN;初始目录=数据库名称;用户ID = sa;密码=密码

,通过这个您可以连接数据库时互联网连接可用,然后你可以用这个连​​接做所有数据库操作。

注意:

首先,远程服务器需要SQL服务器设置允许远程连接。

参考下面的链接来设置SQL服务器,

1. 如何在SQL Server 2008中启用远程连接?

2. 如何配置SQL Server Express以允许远程tcp端口1433上的/ ip连接?


在客户端PC上准备数据库(使用与服务器上相同的结构),并仅将该数据库用于具有应用程序的事务。并按时间间隔将脱机数据同步到在线数据。

为此您可以创建和Windows服务或sql作业,甚至可以使用按时间间隔执行的sql sync算法。


I am developing windows application.Client wants it to work online (if internet connection is available)and offline(if no internet connection) .offline Data Should Update For online Database (if internet connection is available)How do I Do it.
I'm Using c# and SQL 2008R2 Please help me .it's very urgent for me..

解决方案

Hi,

Just keep it your database in a server. Develop your client application with local database and you what you want. Followings are the references.

1. To check the internet connection - Testing Internet Connectivity.

2. Connection string for the database deployed in the server,

Data Source=ipadress\SQLEXPRESS;Network Library=DBMSSOCN;Initial Catalog=databasename;User ID=sa;Password=password

, by this you can connect your database when the internet connection available, then you can do all the database operations with this connection.
Note:
Before all, SQL server in remote server needs to setup to allow remote connections.
Refer below links to setup SQL server,
1. How to enable remote connections in SQL Server 2008?
2. How do I configure SQL Server Express to allow remote tcp/ip connections on port 1433?


Prepare database on client pc (Use same structure as on server) and use that database only for transactions with application. and sync that offline data to online data on time interval.
For that you can create and windows service or sql jobs or even yo can use sql sync algorithm which executes on time interval.


这篇关于如何创建windows c#应用程序以在线和离线工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆