Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • saintwright 69 posts 77 karma points
    Jun 18, 2011 @ 10:02
    saintwright
    0

    How to connect to a different DB

    Hi

     

    I have some data in in a an SQL DB (not the umbraco one) that I want to display on my website - I thought I could do this via razor.  I am not sure how to open up a connection to the db - the connection string is in teh config file, I tried:

    @using System.Data
    @using System.Linq
    @using System.Xml.Linq


    @{

          var DB = Database.Open("pubsConnection");
     }

    but I get The name 'Database' does not exist in the current context


    When I try via Linq I also get a does not exist am I missing some @using?

  • Lesley 284 posts 143 karma points
    Jun 19, 2011 @ 22:06
    Lesley
    0

    Hi, I believe Database is a helper class inside the WebMatrix.Data namespace. So you need @using WebMatrix.Data

    Hope that does the trick!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies