Click here to Skip to main content
15,924,935 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
this one works perfectly?
but when i open this in another pc it will give an error message.

i know database file in destination C:\\

but cant i copy that database file in project folder where i can bring this any where by copying it to my pen.

i have created a same database folder in another machine? but that also won't work?

when i open this in another pc it gives me an error saying?

Unhandled exception has occured in your application. if you click continue, the application will ignore this error and attempt to continue. if you click quit, the application will close immediately.

Could not load file or assembly 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=netural, PublicKey Token=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

What i can do for this?

C#
string connetionString = null;

            //string sql = null;
            string name = "";
            string pass = "";

            connetionString = "Data Source=C:\\Users\\businesssupport\\Documents\\stockDb.sdf";

            using (SqlCeConnection con = new SqlCeConnection(connetionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //

                using (SqlCeCommand command = new SqlCeCommand("SELECT * FROM Login WHERE userName=@Usr", con))
                {

                    command.Parameters.AddWithValue("@Usr", uName.Text);
                    SqlCeDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        name = reader.GetString(1);  // Name string
                        pass = reader.GetString(2); // Password string
                    }

                    if (name == uName.Text && pass == uPass.Text)
                    {

                        //ClassEnq.Uname = UName.Text;
                        MessageBox.Show("Password Accepted");
                        //this.Close();
                        //setEnableToolStripMenuItem(true);
                        //setEnableToolStripMenuItem1(true);
                        //setDisableToolStripMenuItem(false);

                    }

                    else
                    {
                        MessageBox.Show("Password Incorrect, Please Re-Enter Your Password");
                        //setEnableToolStripMenuItem(false);
                        //setEnableToolStripMenuItem1(false);
                    }
                }
Posted
Updated 10-May-15 23:01pm
v2

1 solution

You have to install SQLce of have the related DLL files : Creating a Private Installation for SQL Compact[^]
 
Share this answer
 

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