如何使用模拟器在智能设备应用程序上配置 SQLCE 连接?

发布于 2024-09-26 22:31:56 字数 626 浏览 1 评论 0原文

我创建了一个简单的测试,打开位于我的台式电脑上的 sqlce 连接 当我开始运行调试模式时,它告诉我它无法打开连接。 我使用 Pocket PC 2003 模拟器

这是我在智能设备应用程序上的测试代码。

连接字符串

private SqlCeConnection conn = new SqlCeConnection("Data Source=C:\\SDB.sdf");

测试连接

public bool test() 
{
    try
    {
        conn.Open();
        {}
        Status.TEXT = "CONNECTED";
    }
    catch (Exception ee) 
    {
        throw ee;
        Status.TEXT = "NOT CONNECTED"; 
    }
    finally
    {
        if (conn.State == ConnectionState.Open) conn.Close(); 
    }
    return true; 
}

需要配置什么吗?谢谢!

I created a simple test that opens a connection of sqlce located on my Desktop P.C.
When i start Run the debug mode it throws me that it cant open the connection.
I use Pocket P.C 2003 EMULATOR

This is my Test Code on my Smart Device Application.

Connection string

private SqlCeConnection conn = new SqlCeConnection("Data Source=C:\\SDB.sdf");

test Connection

public bool test() 
{
    try
    {
        conn.Open();
        {}
        Status.TEXT = "CONNECTED";
    }
    catch (Exception ee) 
    {
        throw ee;
        Status.TEXT = "NOT CONNECTED"; 
    }
    finally
    {
        if (conn.State == ConnectionState.Open) conn.Close(); 
    }
    return true; 
}

Is there things need to configure?Thanks in Regards!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽袖吟 2024-10-03 22:31:56

这是正确的行为。在大多数方面,模拟器就像 PC 旁边的物理设备。它不知道您的 PC 驱动器(您可以通过进入模拟器配置来共享 PC 文件夹),因此无法看到它们。它也不知道有关驱动器号的任何信息。

如果您希望模拟器使用 PC 上的文件,您可以再次共享该文件所在的文件夹,然后该文件夹将位于 \storage card\myfile.sdf。请注意,共享文件夹在模拟器上作为“存储卡”安装。

不过,我仍然建议不要这样做,因为它根本不可扩展或可扩展。真正的解决方案不会在您的 PC 上的模拟器上运行,不是吗?当您在无法像模拟器一样共享文件夹的真实硬件上进行测试时会发生什么?我想说你应该将数据库文件部署到你的设备上,无论是模拟器还是真机。

That's correct behavior. For most aspects, the emulator is just like a physical device that is nesxt to your PC. It doesn't know about your PC drives (you can share a PC folder by going into the Emulator configuration) and therefore can't see them. It also doesn't know anything about drive letters.

If you want the emulator to use a file on your PC, again you can share the folder the file is in, then it would be located at \storage card\myfile.sdf. Note that the shared folder gets mounted as "storage card" on the emulator.

I'd still recommend not doing this, though, since it's not at all extensible or scalable. The real solution isn't going to be running on an emulator on your PC is it? What happens when you test on real hardware that can't share a folder like the emulator? I'd say you should be deploying the database file to your device, whether that's the emulator or real iron.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文