Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
Hi, I believe Database is a helper class inside the WebMatrix.Data namespace. So you need @using WebMatrix.Data
Hope that does the trick!
is working on a reply...
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.
Continue discussion
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?
Hi, I believe Database is a helper class inside the WebMatrix.Data namespace. So you need @using WebMatrix.Data
Hope that does the trick!
is working on a reply...
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.