Do I need to do anything "special" to use the WebMatrix database helper in Visual Studio '12?

133 Views Asked by At

I'm doing some basic db querying in WebMatrix.

Something like,

@{
  var db = Database.Open("test"); //test is the name of my database
  var selectQuery = "SELECT * FROM MY_CUSTOM_TABLE"
}

//Doing a `@foreach` and showing the items from the table

When I do the same thing in Visual Studio,

I get an error Connection String not found at var db = Database.Open("test");.

Am I missing some using statements? or am I doing something utterly wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

First issue was,

I hadn't defined a connection string in my web.config.

I did that and it gave me an Instance Error.

That took a while solving cause of weird escape sequence behavior. This helped me.