同步客戶端資料庫(SSCE)跟伺服器端資料庫
(本篇為SqlServer給SSCE中匯入資料)
//The Function Can Synchronous any Sever Database with Interface of System.Data.IDbConnection
//This Procedures can be used in Embed Platform of wince becouse
//its resource can be supported by .NET Compact Framework
//This Class is in different Project of Wince Platform and can be used by the Windows Application
using System;
using System.Data ;
using System.Data .SqlServerCe ;
namespace EmbedDB
{
public class SyncServer
{
/// <summary>
/// Copy DataBase Data from any Server Edition to Client of Sql Server Compact Edition
/// </summary>
/// <param name="srcConnection">connection object of Source Database</param>
/// <param name="destConnection">connection object of Target Database</param>
/// <param name="queryString">inquire clause of Source Database</param>
/// <param name="destTableName">Table Name of Target Database</param>
/// <remarks >Suppose the target Table of SSCE Database is Exist</remarks>
public static void CopyTable(
IDbConnection srcConnection,
SqlCeConnection destConnection,
string queryString,
string destTableName)
{
IDbCommand srcCmd = srcConnection.CreateCommand();
srcCmd.CommandText = queryString;
SqlCeCommand destCmd = destConnection.CreateCommand();
//SSCE provide the visit pattern of table,with the parameter of seek inquirying is more efficiency
//than the pattern of where.
destCmd.CommandType = CommandType.TableDirect;
destCmd.CommandText = destTableName;
try
{
IDataReader srcReader = srcCmd.ExecuteReader();
SqlCeResultSet resultSet = destCmd.ExecuteResultSet(
ResultSetOptions.Sensitive | //The ResultSet detects changes made to the data source
ResultSetOptions.Scrollable | //The ResultSet can be Scrolled both forward and backward
ResultSetOptions.Updatable); //The ResultSet allows Updates
object [] values;
SqlCeUpdatableRecord record;
while (srcReader.Read())
{
//Read Items From Resource DataSet
values = new object [srcReader.FieldCount];
srcReader.GetValues(values);
//Insert Items Through RecordSet
record = resultSet.CreateRecord();
//the fields of the DataBase Table in Server Must Keep compatible with The Client Table
record.SetValues(values);
resultSet.Insert(record);
}
srcReader.Close();
resultSet.Close();
}
catch (Exception e)
{
System.Console.WriteLine(e.Message);
}
}
}
}
//The Master of Test on PC,IF Running on Wince or other embed system
// need to Import System.Data.SqlClient.dll and alter the connective style with server
// To Get System.Data.SqlClient.dll:
//(VS2008)Upload a sql.ppc.wce4.arcv4.CAB to WinCE Emulator from
//D:/Program Files/Microsoft Visual Studio 9.0/SmartDevices/SDK/SQL Server/Client/v2.0/wce400/armv4,
//and double clicking will Create a folder under windows,enter the folder will find two files,its name
//are dbnetlib.dll and system.data.sqlclient.dll.The second are the needed.
//(OR)find System.Data.SqlClient.dll from
//C:/Program Files/Microsoft SQL Server Compact Edition/v3.5/Devices/Client
//(OR VS2005) can find it from
//D:/Program Files/Microsoft Visual Studio 8.0/SmartDevices/SDK/SQL Server/Client/v2.0,
//This Procedures Only Run on the Windows for the namespace of
//System.Data.SqlClient living on the windows only
using System;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using EmbedDB;
namespace TestWindows
{
class Program
{
static void Main(string[] args)
{
TestLink();
}
/// <summary>
/// Test The Function of EmbedDB.SyncServer.CopyTable(...)
/// </summary>
public static void TestLink()
{
string srcConnstring = "Data Source=.;Initial CataLog=ManufactureManage;Integrated Security=True";
//string srcConnstring = "Data Source=123-suoxd;Initial Catalog=ManufactureManage;User Id=sa;Password=suoxd123;"
SqlConnection srcConnection = new SqlConnection(srcConnstring);
EmbedDB.SqlCE asd = new SqlCE("DBRunInfo.sdf");
string destConnstring = "Data Source=DBRunInfo.sdf";
SqlCeConnection destConnction = new SqlCeConnection(destConnstring);
try
{
srcConnection.Open();
destConnction.Open();
EmbedDB.SyncServer.CopyTable(srcConnection, destConnction,
"Select ONumber as uNumber,OPower as uGrade,OID as userID,OName as uName,OPwd as uPwd From dbo.Operator",
"UserInfo");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
srcConnection.Close();
destConnction.Close();
}
}
}
}
reference from :http://www.searchdatabase.com.cn/showcontent_21968.htm
相關推薦
同步客戶端資料庫(SSCE)跟伺服器端資料庫
(本篇為SqlServer給SSCE中匯入資料) //The Function Can Synchronous any Sever Database with Interface of System.Data.IDbConnection//This Procedures can be used in Em
利用socket技術實現用java實現客戶端向服務端傳送檔案,伺服器端接收檔案並給出一個響應。
通訊是網路程式設計中重要的組成部分,而socket程式設計是網路程式設計的基礎。利用socket可以實現客戶端和伺服器端的通訊。下面我先把客戶端和伺服器端的程式碼粘上去再進行詳細的分析。 package test1; import java.io.File; import java.io
TCP實現多個客戶端同時向同一個伺服器端傳送圖片,也可以同一個客戶端多次向伺服器傳送圖片。當上傳圖片大於一定的限度(這裡指定為了10k)時,則停止上傳,將已經接收到但未接收完的檔案刪除。
伺服器端: //多使用者上傳圖片 import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class UploadPicServer1 { public sta
C#伺服器端與客戶端的通訊(伺服器端)
Tcp協議+socket 1.伺服器端開始監聽 //通過winform視窗輸入的伺服器ip地址和埠號 myip = IPAddress.Parse(textBox1.Text); myport = Int32.Parse(textBox2.Text);
客戶端提交資料給伺服器端,如果資料中帶有中文的話,有可能會出現亂碼情況
request: 如果是GET方式 程式碼轉碼 String username = request.getParameter("username"); String password = request.getParameter("password"); String use
Android客戶端通過TCP接收伺服器端傳送的資料
引言 因為我確實不懂TCP通訊這一塊兒,最近專案中要實現客戶端接收伺服器端傳送過來的資料(這個資料是int型的,範圍是0~360,而且伺服器端用C語言寫的,每一秒傳送一次,客戶端只需要不斷接收就好了),很開心的用BufferedReader讀取資料,結果發現一直讀取不到資
Linux下簡單的網路程式設計筆記(模擬簡單的伺服器與客戶端的通訊 1-伺服器端)
一.伺服器端 (一).建立連線的條件:伺服器必須處於監聽狀態,由客戶端發起連線請求 bind之前可新增以下程式碼解決關閉伺服器後端口仍被佔用的問題 // 設定套接字選項避免地址使用錯誤 int on=1; if((setsoc
TCP程式設計例三:從客戶端傳送檔案給伺服器端,伺服器端儲存到本地,並返回“傳送成功”給客戶端。
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.i
客戶端跳轉與伺服器端跳轉的區別以及路徑
客戶端跳轉時用HttPservletResopse物件的sendRedirect函式實現,伺服器端跳轉是使用RequestDispather物件的forward方法實現的。這兩者之間的區別主要體現在三個方面: 1. 使用伺服器端跳轉時,客戶瀏覽器的位址列並不會顯示目標地址的
Android 使用mina框架 搭建socket客戶端,進行與伺服器端通訊
注意: 在設定編碼過濾的時候 一定要注意 伺服器端和客戶端的編碼要一致 mina框架解釋 簡單理解就是 :封裝了底層的讀寫流操作,提供高階操作API的通訊框架 當前發行的 MINA 版本支援基於Java NIO 技術的 TCP/UDP 應用程式開發、串
android客戶端呼叫介面與伺服器端互動 如何保持session
最近在開發安卓介面的過程中,遇到android與web伺服器要在同一session下通訊的問題。 在解決問題前先回顧下Session與Cookie: Cookie和Session都為了用來儲存狀態資訊,都是儲存客戶端狀態的機制,它們都是為了解決HTTP無狀態的問題而
客戶端跳轉與伺服器端跳轉的區別
客戶端跳轉時用HttPservletResopse物件的sendRedirect函式實現,伺服器端跳轉是使用RequestDispather物件的forward方法實現的。這兩者之間的區別主要體現在三個方面:1. 使用伺服器端跳轉時,客戶瀏覽器的位址列並不會顯示目標地址的U
移動端使用token向伺服器端驗證使用者身份
最近做一個移動APP的專案,當用戶登陸一段時間後從客戶端請求伺服器時需要驗證使用者身份,通常在web中的做法都是使用session或cooike來保持會話,但是放到手機端肯定是不合適的。
關於客戶端與資料庫伺服器端的時間同步問題
這是一個做C/S的管理軟體開發時經常被忽略的問題,客戶端的時間與伺服器的時間如果有偏差,資料統計、報表等等肯定會有“意外”的情況發生。 意圖很簡單:從資料庫伺服器獲取到時間,根據這個時間修改當前客戶端電腦時間。 用Sql的函式getdate(),是比較容易的。 我們是基於do
記筆記:C# Socket客戶端監聽伺服器端處理方案【同步】
方案主要功能: (1)客戶端同步監聽來自伺服器端的資料(開啟子執行緒監聽) (2)客戶端向伺服器端傳送資料(主執行緒傳送,並控制)
Android手機客戶端通過JSP實現與Tomcat伺服器端通訊(Msql資料庫,Json作為載體)--服務端程式碼
伺服器端主要程式碼: 1.首先構建一個Person類,用來儲存使用者資訊 public class Person private String name; private String address; private Integer age; public P
客戶端實現正確的伺服器時間同步
一、問題描述 需要解決的問題很簡單,就是如何在頁面上比較準確的顯示伺服器時間。目前比較常用的方法就是根據基準時間使用setTimeout或 setInterval來計算最新的時間,這樣的問題在於setTimeout與setInterval的時間精度比較低,經測試一分鐘大概能相差幾秒 (與電腦效能以及執行
cocos creator專案實戰全套(客戶端,伺服器,資料庫)視訊教程
問題諮詢 為了避免由於網頁溝通的不及時所引起的誤會,特提供客服QQ:1927832684 普通學員交流群:572270243 有問題及時反饋,避免發生不必要的誤會! 課程簡介課程特色:專案為主,一切跟著專案走,拒絕高大上,拒絕瞎比比,腳踏實地,實踐為主! 課程內容:
配置ntp客戶端與伺服器端時間的同步
1,實驗機器介紹 Ip地址 伺服器1 192.168.245.128 伺服器2 192.168.245.130 客戶端1 192.1
php webservice實現客戶端提交資料庫資料到伺服器並返回另一份資料庫資料
由於公司需求,需使用webservice來開發公司erp的伺服器和客戶端的兩邊資料庫交換。 即每次把客戶端更新的資料上傳到生產用的伺服器端並把伺服器端剛更新的資料返回回來。(伺服器端有指令碼在執行更新資料) 由於使用的是php語言,當前網路上大部分解決上傳問題的都是jav