为什么这段代码 在XP上面可以运行,在windows CE上面就不能运行呢

tianhuo_soft 2008-07-29 04:17:07

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=192.168.0.1;Initial Catalog=database;Persist Security Info=True;User ID=sa;Password=abcd";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandTimeout = 0;
cmd.CommandText = " select top 1 * from address";


SqlDataReader reader = cmd.ExecuteReader();

int i = 0;
while (reader.Read())
{
i++;
kstx_time.Text = reader[0].ToString();
txwc_time.Text = reader[1].ToString();
hgyh_time.Text = reader[2].ToString();
yhwc_time.Text = reader[3].ToString();
zxwc_time.Text = reader[4].ToString();
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
zxwc_time.Text = ex.Message;
}



为什么这段代码 在XP上面可以运行,在windows CE上面就不能运行呢

我的windwos CE、xp 都使用无线环境,
但是 CE里面提示 platformNotSupportedException 这个错误

我尝试了 如果没有无线信号的情况下 报 SqlException这个错误
...全文
175 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
ericzhangbo1982111 2008-07-31
  • 打赏
  • 举报
回复
ce不能这样写
ce和pc用的不是一样的类库

你要想访问sql 可以使用webservice来访问
paulin 2008-07-31
  • 打赏
  • 举报
回复
学习~
流浪孩儿 2008-07-31
  • 打赏
  • 举报
回复
CE下这句也是必不可少的


using System.Data.SqlServerCe;
流浪孩儿 2008-07-31
  • 打赏
  • 举报
回复
我在CE下都是这么用的

// open the database.
cn = new SqlCeConnection("Data Source=\\Storage\\prac3.sdf");
cn.Open();

//Create the structure of the database using SQL statements.
// Create the Titles table.
String SQL = " "; //your sql order
SqlCeCommand cmd = new SqlCeCommand(SQL, cn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
流浪孩儿 2008-07-31
  • 打赏
  • 举报
回复
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=192.168.0.1;Initial Catalog=database;Persist Security Info=True;User ID=sa;Password=abcd";

CE下,好像格式不是这么写的吧!
jmh521 2008-07-31
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 kbryant 的回复:]
友情帮顶
[/Quote]
slimfeng 2008-07-31
  • 打赏
  • 举报
回复
哪位大侠能说一下ce版本中数据库、类库以及其他方面与非ce版本的区别。
yagebu1983 2008-07-31
  • 打赏
  • 举报
回复
关注!!
学习!!
exy337 2008-07-31
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 vrhero 的回复:]
Platform Not Supported...提示清清楚楚...

WinCE不支持SQL Server...只支持SQL Server CE...此外.NET Framework CF和.NET Framework有很大差异...大多数PC上能用的类库都不能用...
[/Quote]
没用过CE,感觉这位说的有点理.
mancinigt 2008-07-31
  • 打赏
  • 举报
回复
有没有安装wince用的framework?
qgj1655 2008-07-30
  • 打赏
  • 举报
回复
有没有using System.Data.SqlClient
tianhuo_soft 2008-07-30
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 jl_lsj 的回复:]
up
[/Quote]
jmh521 2008-07-30
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 kbryant 的回复:]
友情帮顶
[/Quote]
mohugomohu 2008-07-29
  • 打赏
  • 举报
回复
环境不支持,没办法
jl_lsj 2008-07-29
  • 打赏
  • 举报
回复
up
vrhero 2008-07-29
  • 打赏
  • 举报
回复
Platform Not Supported...提示清清楚楚...

WinCE不支持SQL Server...只支持SQL Server CE...此外.NET Framework CF和.NET Framework有很大差异...大多数PC上能用的类库都不能用...
tianhuo_soft 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 flon 的回复:]
192.168.0.1
改为 你自己的机器名称
[/Quote]

晕 ~!
wdgphc 2008-07-29
  • 打赏
  • 举报
回复
按道理说XP下能跑的XPE/CE下都能想办法跑起来,看看CE中是不是裁剪掉了什么组件.
zhouchunping_99 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 flon 的回复:]
192.168.0.1
改为 你自己的机器名称
[/Quote]
flon 2008-07-29
  • 打赏
  • 举报
回复
192.168.0.1
改为 你自己的机器名称
加载更多回复(3)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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