Hi,
I'm trying to connect a drop down list to a table in my database. How do i establish a connection to a database? select a table and then bind that to the control? i've been toying for hours trying to do it and the best i can come up with is:
protected void Page_Load(object sender, EventArgs e)
{
try
{
Config.GetConnectionString("SiteSqlServer");
StringBuilder sb = new StringBuilder();
sb.Append("select * From RemoveModule");
ddlPortalName.DataSource = DotNetNuke.Data.DataProvider.Instance().ExecuteSQL(sb.ToString());
ddlPortalName.DataTextField = "PortalName";
ddlPortalName.DataValueField = "PortalName";
ddlPortalName.DataBind();
}
catch (Exception ex)
{
//If the module fails to load
Exceptions.ProcessModuleLoadException(this, ex);
}
}
I know i have to use a connection string somewhere and the best i could find is
Config.GetConnectionString("SiteSqlServer");
but how do i use it? or where? once i have a connection is the code above enough to fill the Drop Down List.
Any suggestions?