Dynamically Open Windows Form based on Database value using C# and VB.Net

Last Reply one year ago By dharmendr

Posted one year ago

Hi

I want open form from database.

Id

nameForm

1

User    

2

mainForm

	    public DataTable getNameForms()
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["depr"].ConnectionString);
            DataTable dt = new DataTable();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "select ltrim(rtrim(nameForm))nameForm from tblPermission where id = 2";
            con.Open();
            try
            {
                dt.Load(cmd.ExecuteReader());
            }
            catch { }
            con.Close();
            return dt;
        }

	    private void btnEnter_Click(object sender, EventArgs e)
        {
	    DataTable d = dep.getNameForms();
            d.Rows[0]["nameForm"] mn = new d.Rows[0]["nameForm"];
	    mn.ShowDialog();
        }

 

This question does not have replies that have been liked.