I'm putting together a dashboard and was told to use mvc3.
I created a .mdf database in visual studio and want to pull the data into a table, but don't know how to do that.
I have a few .cshtml files where I need the data to go.
I tried:
@{
ViewBag.Title = "test";
var db = System.Data.Entity.Database.Open("L1DB.mdf");
var grid = new WebGrid(db.Query("SELECT * FROM MetricOwner"));
}
but the
.Open() part returns an error.
I've never done anything like this before, so I'm completely lost.
4 Replies - 666 Views - Last Post: 09 July 2012 - 01:12 PM
Replies To: pull data from database into a table visual studio
#2
Re: pull data from database into a table visual studio
Posted 09 July 2012 - 12:34 PM
what error does it give?
#3
Re: pull data from database into a table visual studio
Posted 09 July 2012 - 12:40 PM
System.Data.Entity.Database. does not contain a definition for Open
#4
Re: pull data from database into a table visual studio
Posted 09 July 2012 - 12:50 PM
do you have code behind?
#5
Re: pull data from database into a table visual studio
Posted 09 July 2012 - 01:12 PM
All I have now is:
test.cshtml:
I will need the info from the DB to go in the <td> elements
test.cshtml:
@{
ViewBag.Title = "test";
var db = System.Data.Entity.Database.Open("L1DB.mdf");
var grid = new WebGrid(db.Query("SELECT * FROM MetricOwner"));
}
<script type="text/javascript">
window.onload = runChart();
</script>
<div id="oveA">
<div id="boxTitle">title</div>
<div class="monthlyGauge">
</div>
<div class="excelChart" id="EA">
<table>
<tr>
<th id = "titles"></th>
<th id = "titles"></th>
<th id = "titles"></th>
<th id = "titles"></th>
<th id = "titles"></th>
<th id = "titles"></th>
<th id = "titles"></th>
</tr>
<tr>
<td id = "content"></td>
<td id = "content"></td>
<td id = "content"></td>
<td id = "content"></td>
<td id = "content"></td>
<td id = "content"></td>
<td id = "content"> </td>
</tr>
</table>
<br /><br />
<ul>
<li><a href="#">Link1</a></li>
<li><a href="#">Link2</a></li>
</ul>
</div><br /><br /><br />
<div class="YTD" id="YTDA">ytd gauge</div>
<div class="Other" id="run"></div>
</div>
I will need the info from the DB to go in the <td> elements
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|