polaris101
asked on
ASP.NET Web page 2, Query question...
I can get this to work when I don't have the second query, but when I do use the second query (foreach loop near bottom) to try to display additional data I get this message:
Compiler Error Message: CS0103: The name 'db' does not exist in the current context. Why does the first query work and not the second?
Compiler Error Message: CS0103: The name 'db' does not exist in the current context. Why does the first query work and not the second?
@{
//member variables are here...
var fname = "";
<.....snip....>
if(!IsPost){
if(!Request.QueryString["MemberID"].IsEmpty() && Request.QueryString["MemberID"].IsInt()){
MemberID = Request.QueryString["MemberID"];
var db = Database.Open("MyDB");
var dbCommand = "SELECT tblMembers.*, tblPractices.* FROM tblMembers, tblPractices WHERE tblMembers.PracticeID = tblPractices.PracticeID AND MemberID = @0 ORDER By tblMembers.Lname";
var dbCommandPods = "SELECT tblPods.*, tblPodMembers.* FROM tblPodMembers INNER JOIN tblPods on tblPodMembers.PodId = tblPods.PodId WHERE MemberId = @0";
var row = db.QuerySingle(dbCommand, MemberID);
if(row !=null){
fname = row.fname;
//more here....
<.....snip....>
}
}
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h2>Detailed Member Information</h2>
<div>
<h3>Basic Info</h3>
<table border="1">
<tr>
<td>Member Name: @fname @MInitial @lname @suffix</td>
</tr>
<tr>
<td>Practice Name: @name</td>
</tr>
<tr>
<td>Date of Birth: @dob</td>
</tr>
<tr>
</tr>
<tr>
<td>Email Address: @email</td>
</tr>
</table>
</div>
<div>
<h3>POD Info</h3>
<table border="1">
@foreach (var recordrow in db.Query(dbCommandPods)){
<tr>
<td> @recordrow.PodName</td>
</tr>
}
<tr>
<td>Practice Manager: @PractManagerFname @PractManagerLname</td>
</tr>
<tr>
<td>Practice Manager Email: @PractManagerEmail</td>
</tr>
</table>
</div>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.