I'm using SQL CE for the first time, so far I haven't had much problems, everything has acted as it should but for some reason I'm having issues with connection String .
After creation of All the Front end i try to connect Application to SqlCE Data Base , the application doesn't show any Debug error but while running it will Show "path is not valid .Check the Directory for Data Base .[path=C:\\Projects\\Master\\Master\\sanjay.sdf]"
try to change the format of connection String But "connString = Properties.Settings.Default.CollectorDBConnectionString;"
but on settings it generate the error
this is my code
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlServerCe;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Master
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void tx1_TextChanged(object sender, EventArgs e)
{
}
private void tx2_TextChanged(object sender, EventArgs e)
{
}
private void sn_Click(object sender, EventArgs e)
{
SqlCeConnection conn = new SqlCeConnection();
conn.ConnectionString ="Data Source=C:\\Projects\\Master\\Master\\sanjay.sdf";
conn.Open();
SqlCeCommand cmd = new SqlCeCommand("INSERT INTO emp(usid,pass) VALUES (@us,@id) ",conn);
cmd.Parameters.Add(new SqlCeParameter("@ns", tx1.Text));
cmd.Parameters.Add(new SqlCeParameter("@id", tx2.Text));
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Insert Data Sucessfully");
tx1.Text = "";
tx2.Text = "";
}
private void can_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}