如何建立与Windows Mobile6.0应用程序的连接到sqlce3.5数据库并将数据存储到数据库中的表 [英] how to make connection to windows mobile6.0 application to sqlce3.5 database and store data to table in database

查看:69
本文介绍了如何建立与Windows Mobile6.0应用程序的连接到sqlce3.5数据库并将数据存储到数据库中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#.net中使用Emulator开发窗口移动应用程序
我想建立连接,然后将数据从窗口mobile6.0应用程序窗体存储到sqlce3.5数据库中
我已经尝试了很多次,但是却遇到了以下问题,


请帮助我
并给我示例代码以将数据从应用程序表单存储到sqlce3.5数据库

hi , i am developing the window mobile application using Emulator in C#.net
i want to make connection and then store data from window mobile6.0 application Form to sqlce3.5 database
i have try many time , i have the following but it not working ,


please help me
and give me the sample code to store data from application form to sqlce3.5 database

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;

namespace SmartDeviceProject3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

       
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                SqlCeConnection cnn = null;
                String str = "Data Source=E:\\mobile\\Mydatabase#1.sdf;Persist Security Info=False";  //data base is located in My Computer/E:/mobile/Mydatabase#1.sdf
                cnn = new SqlCeConnection(str);
                SqlCeCommand cmd = new SqlCeCommand();
                cmd.Connection = cnn;
                cmd.CommandType = CommandType.Text;
                cmd.Connection = cnn;
                cmd.CommandType = CommandType.Text;
                cnn.Open();
                cmd.ExecuteNonQuery();
                cmd = null;
                MessageBox.Show("data store successfully");
                cnn.Close();
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
            }
        }
    }
}

推荐答案

String str = "Data Source=E:\\mobile\\Mydatabase#1.sdf;Persist Security Info=False"; //data base is located in My Computer/E:/mobile/Mydatabase#1.sdf

不,不是.

请记住,Windows Mobile模拟器就是这样:一个模拟器.这意味着它伪装成真正的Windows Mobile设备.
如果它是正版Windows Mobile设备,它可以访问您的硬盘吗?
在任何时候,而不是何时对接?
编号
它可以访问存储卡和内部存储器.但不是您的PC.

将其放在仿真器的内部存储器中,或在仿真器上设置存储卡仿真,然后将其粘贴在其中.然后将连接字符串指向该位置.例如:

No it isn''t.

Remember that the windows mobile emulator is just that: an emulator. What that means is that it pretends to be a genuine Windows Mobile device.
If it was a genuine Windows Mobile Device, could it access your hard drive?
At any time, rather then when it was docked?
No.
It can access storage cards and internal memory. But not your PC.

Put it in the emulators internal memory, or set up a storage card emulation on the emulator, and stick it in there. Then point the connection string at that. For example:

string str = @"Data Source=\Storage Card\PAAssociation\Membership\Details.sdf;Password=XXXXXXXXXXXXX;Persist Security Info=True";


这篇关于如何建立与Windows Mobile6.0应用程序的连接到sqlce3.5数据库并将数据存储到数据库中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆