我已经使用 Visual Studio 2010 创建了 ac# windows 窗体应用程序,我现在想为我的应用程序创建一个安装程序 exe 文件,问题是,它需要一个数据库才能运行,我的问题是如何在我的设置中包含这个数据库。
我使用 Oracle sql developer 创建了数据库。
我正在使用本地连接,即。“系统-XE”
这是程序如何与数据库通信的代码片段。
            string oradb = "Data Source=localhost:1521/XE;User Id=system;Password=5853123;";
        OracleConnection conn = new OracleConnection(oradb);
        try
        {
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SELECT username from administrators where password = " + textBox2.Text;
            cmd.CommandType = CommandType.Text;
            OracleDataReader dr = cmd.ExecuteReader();
            conn.Close();
            loggedIn = true;
            Close();
        }
        catch(Exception){
                MessageBox.Show("Incorrect Credentials, please try again.");
            }
        finally
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
        loggedIn = true;
        Close();