Start New Discussion within our Software Development Community

Okay,

I created an application that used SQL. It works perfect on the computer that I compiled it on, but, when I release the application it shows an error like:

"Cannot open this application, missing components" ...

Also, on the computer I compiled it on, it shows the database file as being an active file.. However, on a different computer.. It shows it as an inactive file..

When I realise the application, do I also need to release the database file and change the directory?

Here is an example of the connection file

public bool checkInitial()
        {
            // connect to the database
            string connection = @"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\program.mdf;Integrated Security=True;User Instance=True";
            
           SqlConnection connect = new SqlConnection(connection);
            try
            {
                connect.Open();
                MessageBox.Show(username);
                SqlCommand login = new SqlCommand("SELECT * FROM students WHERE first_name='" + username + "' AND inititalAssessment = '0'", connect);

                SqlDataReader reader = null;

                reader = login.ExecuteReader();
                if (!reader.Read())
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            catch (Exception)
            {
                return false;

            }
        }
    }

Where would the database file need to be, if I was to realise it?

Please, please help me..

This article has been dead for over six months. Start a new discussion instead.