Click here to Skip to main content
12,502,116 members (55,719 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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 :
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 8-Nov-12 4:04am
gottik107
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100