Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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);
            }
        }
    }
}
Posted
Updated 13-Oct-10 1:36am
v2

1 solution

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
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:
MIDL
string str = @"Data Source=\Storage Card\PAAssociation\Membership\Details.sdf;Password=XXXXXXXXXXXXX;Persist Security Info=True";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900