Typically what we do is add the connection string in the web.config OR add it as a constant string.  Then load the connection via the API and make calls as needed.  Something like this:
GeneralConnection conn = ConnectionHelper.GetConnection(SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".SettingsKeyCodeName"));
using (GeneralConnection cn = conn)
    {
        try
        {
            cn.Open();
            DataSet ds= cn.ExecuteQuery("query.name.from.custompage.type");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // do some work here
            }
        }
        catch {}
    }
This shows you storing your connection string in a settings key within Kentico.  You can also store it in the web.config and get it from there too.  
Another thing it shows is storing your queries or stored procedures within a custom page type that is only a placeholder for transformations and queries.  This will allow you to take advantage of the virtual objects without needing to update your custom code all the time.