| Author: vipul 12 Aug 2008 | Member Level: Diamond | Rating: Points: 4 |
hi, you write wrong syntax you write string mstCon = "\\My Documents\\Northwind.sdf"; ??? Where to find it you write this way string mstCon = "C:\\My Documents\\Northwind.sdf";
you write full path where this database resid.
vipul, http://dongavipul.blogspot.com
Patel Vipul Web Developer Ahmedabad ( Gujarat )
|
| Author: matej 12 Aug 2008 | Member Level: Bronze | Rating: Points: 2 |
thenks for quickly response. yes for the computer must be c:\my document. but for the device i`m not sure that is the correct.
|
| Author: matej 12 Aug 2008 | Member Level: Bronze | Rating: Points: 4 |
i`ve solve the problem. ther is solution. thanky anyway
SqlCeConnection conn = new SqlCeConnection("Data Source = \\My Documents\\Northwind.sdf; Password =''"); conn.Open(); SqlCeCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO test (ID) Values(17)"; cmd.ExecuteNonQuery();
|
| Author: syed shakeer hussain 02 Dec 2008 | Member Level: Gold | Rating: Points: 6 |
Hi.. I am sending a code
using System; 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 HMS { public partial class Login : Form { public Login() { InitializeComponent(); } SqlCeConnection conn; SqlCeDataAdapter adapter; SqlCeCommandBuilder builder; DataSet ds;
private void btnSingIn_Click_1(object sender, EventArgs e) { if (txtuserid.Text != "" && txtpassword.Text != "") {
if (validcheck()) { txtuserid.Text = ""; txtpassword.Text = ""; HOMEPAGE obj = new HOMEPAGE(); obj.ShowDialog(); } else { MessageBox.Show("invalid user"); } } else MessageBox.Show("Plz Enter UserId and Password");
}
private void btnCancel_Click_1(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; txtpassword.Text = ""; txtuserid.Text = ""; HOSPITALMANAGEMANT obj = new HOSPITALMANAGEMANT(); obj.ShowDialog(); Cursor.Current = Cursors.Default; } private bool validcheck() { Cursor.Current = Cursors.WaitCursor; SqlCeConnection conn1 = new SqlCeConnection("DataSource=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyDatabase#1.sdf "));
SqlCeCommand cmd = new SqlCeCommand("select userid,password from login where userid='" + txtuserid.Text + "'and password='" + txtpassword.Text + "'", conn1); SqlCeDataReader reader; conn1.Open(); reader = cmd.ExecuteReader(); bool valid = false; while (reader.Read()) { valid = true; } reader.Close(); conn1.Close(); Cursor.Current = Cursors.Default; return valid;
}
private void Login_Load(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; conn = new SqlCeConnection("DataSource=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyDatabase#1.sdf ")); conn.Open(); adapter = new SqlCeDataAdapter("select * from login", conn); builder = new SqlCeCommandBuilder(adapter); ds = new DataSet(); adapter.Fill(ds, "login"); conn.Close(); Cursor.Current = Cursors.Default; }
private void LnkNewuser_Click_1(object sender, EventArgs e) { NEW_USER newobj = new NEW_USER(); newobj.ShowDialog(); }
private void label4_ParentChanged(object sender, EventArgs e) {
} } }
|