How to connect to database at runtime

3 posts, 1 answers
  1. Atle
    Atle avatar
    5 posts
    Member since:
    May 2009

    Posted 09 Jul 2009 Link to this post

    I am new to Telerik controls so don't understand all of the consepts yet. I have been playing with the Scheduler since it is the first component I need to implement.
    I have a SQL Server and I used the datasource wizzard to connect. Things are working just fine. But my real life application needs to connect to many different databases with the exact same structure at run time depending on logged in user (I have several users and each of them have their own database on the same server).

    So my question is how can I override the connectionstring (or some other method) in code behind to change the database name just before the Scheduler loads?


  2. Answer
    Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 10 Jul 2009 Link to this post

    Hello Atle,

    Here is one idea:

    1. You have an SQL Datasource set up on the page (e.g. the Select, Update, Insert and Delete queries are there).

    2. You have RadSCheduler on the same page - all settings are set except the DataSourceID property.

    3. In Page_Load of the page you set the connection string of the datasource, set the DataSourceID property of the Scheduler to point to that datasource and call the DataBind() method of the scheduler.

    I hope this will get you started.

    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Michael
    Michael avatar
    72 posts
    Member since:
    Mar 2007

    Posted 14 Feb 2011 Link to this post


    I'll use Data binding (DataSource property) with custom Advanced form embeded into a RadWindow - customized editing form(s); also I want to alter database structure in this manner:
    - In Appointments table: will transform ID type from int to Guid; therefore Appointment business object will have the ID as Guid so is there any issue with binding Scheduler with custom objects? Should I espect unusual behavior in displaying information in RadScheduler?

Back to Top