SQL Mobile如何实现同步

feishanm 2008-03-04 09:13:14
下面是我写的SQL mobile 与SQL 2000同步 ,运行程序时总是出现"运行IIS的计算机出错,请尝试重新启动IIS服务器。"。
已经重启了很多次了,还是不行。
在浏览器中能“http://127.0.0.1/SQLCE/sqlcesa30.dll”打开它,显示:SQL Server Mobile Server Agent 3.0
SQL server 数据库已经添加了IUSR_用户。
哪位大哥知道是怎么回事吗?或者哪里配置有错误。
另外哪位可以发个SQL mobile同步例题给我吗?Mail:feishanmin@163.com
万分感谢!!!

public void CaseSynchronizationS()
{
// Connection String to the SQL Server.
string rdaOleDbConnectString = "Provider=sqloledb; Data Source=PPC;Initial Catalog=Northwind; " + "User Id=sa;Password=fei";
// Initialize RDA Object.
SqlCeRemoteDataAccess rda = null;

try
{
//Try the Pull Operation.
rda = new SqlCeRemoteDataAccess();
rda.InternetUrl = "http://127.0.0.1/SQLCE/sqlcesa30.dll";
rda.LocalConnectionString = ("Data Source ="
+ (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
+ ("\\ajData.sdf;"
+ ("Password =" + "\"fei\";"))));
rda.Pull("ss", "select sname,ssex from s ", rdaOleDbConnectString,RdaTrackOption.TrackingOnWithIndexes);
}
catch (Exception msex)
{
MessageBox.Show(msex.Message.ToString());
}
finally
{
//Dispose of the RDA Object.
rda.Dispose();
}
...全文
210 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghd2004 2008-03-10
  • 打赏
  • 举报
回复
以前好像解决过类似问题
feishanm 2008-03-06
  • 打赏
  • 举报
回复
问题已经解决
原因是PDA没有设置好网络,不能访问本地机器
youth0826 2008-03-06
  • 打赏
  • 举报
回复
sqlcesa30.dll不能是127.0.0.1或者localhost
可以用计算机名或者局域网ip
这样pda才能访问pc
OceanRain 2008-03-05
  • 打赏
  • 举报
回复
Config文件的属性值如下设置:
InternetPwd sh.0114
InternetServer http://10.4.15.33/sqlce/Sqlcesa30.dll
InternetUser centaline\\shiyf01
LocalDatabase \My Documents\ga.sdf
RemoteConnect
Provider=sqloledb; Data Source=SHCDN56T; Initial Catalog=test; Persist Security Info=True;User ID=sa;Password=g00dbye~!@#$%

/// <summary>
/// 以下信息应该从PDA上的配置文件或者资源文件读取
/// </summary>
public class Config
{
private static readonly string m_internetServer;
private static readonly string m_internetUser;
private static readonly string m_internetPwd;
private static readonly string m_remoteConnect;
private static readonly string m_localDatabase;

static Config()
{
m_internetServer = Properties.Resources.InternetServer;
m_internetUser = Properties.Resources.InternetUser;
m_internetPwd = Properties.Resources.InternetPwd;
m_remoteConnect = Properties.Resources.RemoteConnect;
m_localDatabase = Properties.Resources.LocalDatabase;
}

/// <summary>
/// SQLCE URL
/// </summary>
public static string InternetServer
{
get
{
return m_internetServer.Trim();
}
}

/// <summary>
/// Internet User
/// </summary>
public static string InternetUser
{
get
{
return m_internetUser;
}
}

/// <summary>
/// Internet Password
/// </summary>
public static string InternetPwd
{
get
{
return m_internetPwd;
}
}

/// <summary>
/// Rmote Connectionstring
/// </summary>
public static string RemoteConnect
{
get
{
return m_remoteConnect;
}
}

/// <summary>
/// Local Database
/// </summary>
public static string LocalDatabase
{
get
{
return m_localDatabase;
}
}

/// <summary>
/// Local Connect
/// </summary>
public static string LocalConnect
{
get
{
return string.Concat("Data Source = ", m_localDatabase);
}
}
OceanRain 2008-03-05
  • 打赏
  • 举报
回复
/// <summary>
/// 从服务器同步客户端数据
/// </summary>
/// <param name="keep">true则先把终端数据push到服务器</param>
public void Pull(bool keep)
{
try
{
SqlCeRemoteDataAccess remote = new SqlCeRemoteDataAccess(Config.InternetServer, Config.InternetUser, Config.InternetPwd, Config.LocalConnect);
if (keep)
{
remote.Push(TABLE_NAME, Config.RemoteConnect, RdaBatchOption.BatchingOff);
}

using (SqlCeConnection cn = new SqlCeConnection(Config.LocalConnect))
{
cn.Open();
SqlCeCommand cmd = new SqlCeCommand("select table_name from information_schema.tables where table_name = @table", cn);
cmd.Parameters.Add(new SqlCeParameter("table", TABLE_NAME));

if (cmd.ExecuteScalar() != null)
{
cmd.CommandText = "drop table " + TABLE_NAME;
cmd.ExecuteNonQuery();
}

remote.Pull(TABLE_NAME, "select id, playername, hole, result from " + TABLE_NAME, Config.RemoteConnect, RdaTrackOption.TrackingOnWithIndexes, "RDAErrors");
}

}
catch (SqlCeException err)
{
throw new Exception(err.Message);
}
}


注:以上代码是测试成功的.其中TABLE_NAME是常量[表名]
OceanRain 2008-03-05
  • 打赏
  • 举报
回复
请确定通过模拟器是否能打开百度,或者网易网站.
nihao38 2008-03-04
  • 打赏
  • 举报
回复
up

7,657

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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