while i run the below code it will not open the connection some time show error in Connection String also show error of Path provided by system in not correct
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();
//SqlCeDataReader dr = null;
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));
//qw.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Insert Data Sucessfully");
tx1.Text = "";
tx2.Text = "";
}
private void can_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}