积极答复者
windows ce 5数据库连接问题

问题
-
我刚接触嵌入式系统对这方面对数据库连接方面有点疑惑,下面是我写的连接代码,已经引入了System.Data.SqlServerCe.dll
System.Data.SqlServerCe.SqlCeConnection con = new System.Data.SqlServerCe.SqlCeConnection("database=192.168.11.44.;Initial Catalog=Test;uid=sa;pwd=123");
con.Open();
SqlCeCommand cmd = new SqlCeCommand();cmd.Connection = con;
cmd.CommandText = "insert into Table1(run) values('zhang')";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();运行这个程序会报:unknown connection option in connection string:Initial Catalog 不知道这问题该如何解决。
答案
-
SqlCeConnection 针对的是本地数据源,如果是远程数据源,您可以尝试SqlCeRemoteDataAccess 类
致礼
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Jesse JiangModerator 2011年7月27日 8:02
- 已标记为答案 gyrenModerator 2011年7月29日 4:14
全部回复
-
您好,
这里的错误是 SQLCE不支持连接字符串中的Initial Catalog 属性。您可以删掉这个字段Initial Catalog=Test; 再试试
您可以参阅这个文档 http://msdn.microsoft.com/zh-cn/library/system.data.sqlserverce.sqlceconnection.connectionstring(v=vs.80).aspx 只有备注里面的ConnectionString 属性是被SQLCE 所支持的。
致礼
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
SqlCeConnection 针对的是本地数据源,如果是远程数据源,您可以尝试SqlCeRemoteDataAccess 类
致礼
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Jesse JiangModerator 2011年7月27日 8:02
- 已标记为答案 gyrenModerator 2011年7月29日 4:14