Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

im making Win Mobile 6 pro aplication and when i click button add should add details from textbox's to database , but when i click buton im always getting same error "The path is not valid" , i try to copy to other folders my DB but result is same, i make new project and new database to try whit new project but again same ... i dont know where im wrong the code where im using is :
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 SmartDeviceProject1
{
    public partial class novart2 : Form
    {
        public novart2()
        {
            InitializeComponent();
        }

        SqlCeConnection cn = new SqlCeConnection("Data Source=C:\\Users\\USER\\Documents\\Visual Studio 2008\\Projects\\SmartDeviceProject1\\Ege.sdf");
        SqlCeCommand cmd = new SqlCeCommand();

        private void menuItem1_Click(object sender, EventArgs e)
        {
            novart f = new novart();
            f.Show();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                cn.Open();
                cmd = new SqlCeCommand ("Insert into Art (mr,group_id,subgroup_id,quantity_on_stock) values('"+txtmr.Text +"','"+txtgr.Text +"','"+txtsubg.Text +"','"+txtqnt.Text +"')", cn);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Update Successfull to the Database");
                cn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
}
Posted
Comments
joshrduncan2012 8-Nov-12 10:09am    
You need to set the Build Action to Content in the file's properties: http://blog.dotnetclr.com/archive/2010/04/15/520.aspx
gottik 8-Nov-12 12:55pm    
that screw my project , thanks to god i have backup!

1 solution

I suspect it is pretty simple: Windows Mobile devices don't have disks, so they don't support "C:" as a device specifier.

I suspect that the whole path "C:\\Users\\USER\\Documents\\Visual Studio 2008\\Projects\\SmartDeviceProject1\\Ege.sdf" is invalid on the mobile device, or on the emulator of the mobile device.
 
Share this answer
 
Comments
gottik 8-Nov-12 12:56pm    
i have alerdy try wihit Data Source = Ege.sdf
OriginalGriff 8-Nov-12 14:02pm    
You probably have to find the file - have you tried opening a OpenFileDialog, locating the file, and looking at the returned path?

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