assaultkitty
asked on
Context Error - 2
I am having problem with this homework problem. It is work that I need to complete prior to doing a Project. Can you help me solve this error?
Error 134 The name 'curUser' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S kywardAvia tion\Login .aspx.cs 15 34 C:\...\SkywardAviation\
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (curUser.Read())
{
Session["flyerID"] = curUser["flyerID"].ToStrin g();
Response.Redirect("ffClubP age.aspx") ;
}
}
}
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="Login.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Skyward Airlines</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="callback_navtop">
<tr>
<td width="56%" height="60" class="logoname">
Skyward Airlines
</td>
<td width="44%">
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="menu">
<tr>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
<div align="center">
<a href="index.htm">Home</a>< /div>
</td>
</tr>
</table>
</td>
<td class="cellbackmenuover">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
<div align="center">
<a href="ffClubPage.aspx"><fo nt color="#20809F">Frequent Flyers</font></a></div>
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuextend" >
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#FFFFFF" class="cellbackhmrightexte nd">
<table width="745" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF">
<table width="745" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="172" rowspan="4" valign="top" class="cellbacksubmenu">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="209" valign="top" class="submenu">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="cellbackpromobtmext end">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td height="350" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="12%" height="45">
</td>
<td width="53%">
</td>
<td width="35%">
</td>
</tr>
<tr valign="top">
<td>
</td>
<td>
<h1>
Frequent Flyer Program</h1>
</td>
</tr>
<tr valign="top">
<td>
</td>
<td>
<h2>
Returning Members</h2>
</td>
</tr>
<tr valign="top">
<td>
</td>
<td>
<form id="loginForm" runat="server">
<div>
<asp:TextBox id="account" runat="server"/>
<asp:TextBox id="password" runat="server"/>
<asp:Label id="badLogin" runat="server"/>
</div>
</form>
<h2>
New Members</h2>
<p>
<a href="Registration.aspx">E nroll in Skyward Airlines Frequent Flyer program.</a>
</p>
</td>
<td>
<div class="c3">
<table width="168" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="images/spic_001.jpg" width="168" height="209" alt="Visual formatting image" />
</td>
</tr>
<tr>
<td height="30" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cellbackhmright">
<tr>
<td width="100%" height="50" bgcolor="#DADADA" class="whiteline">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td class="promotext">
New Frequent Flyer members can now earn 2,000 Bonus Miles for taking their first
flight.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr valign="top">
<td height="30">
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF" class="btmmenu">
</td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF" class="btmmenu">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="12%">
</td>
<td width="76%" class="btmmenu">
<a href="index.htm">Home</a> | Frequent Flyers<br />
© 2010 Skyward Airlines
</td>
<td width="12%">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF" class="btmmenu">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
</p>
<p>
</p>
<p>
</p>
</body>
</html>
I have tried to solve this on my own. I am using this page from the text to develop this program. The variable curUser is not a global variable. I cannot figure out why I am getting this error.
curUser.Read---0002.pdf
Error 134 The name 'curUser' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S
using System;
using System.Collections.Generic
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (curUser.Read())
{
Session["flyerID"] = curUser["flyerID"].ToStrin
Response.Redirect("ffClubP
}
}
}
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="Login.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Skyward Airlines</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="callback_navtop">
<tr>
<td width="56%" height="60" class="logoname">
Skyward Airlines
</td>
<td width="44%">
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="menu">
<tr>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
<div align="center">
<a href="index.htm">Home</a><
</td>
</tr>
</table>
</td>
<td class="cellbackmenuover">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
<div align="center">
<a href="ffClubPage.aspx"><fo
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuunder">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtmenu">
<img src="images/spacer.gif" width="95" height="1" alt="Formatting image" />
</td>
</tr>
<tr>
<td class="txtmenu">
</td>
</tr>
</table>
</td>
<td class="cellbackmenuextend"
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#FFFFFF" class="cellbackhmrightexte
<table width="745" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF">
<table width="745" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="172" rowspan="4" valign="top" class="cellbacksubmenu">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="209" valign="top" class="submenu">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="cellbackpromobtmext
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td height="350" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="12%" height="45">
</td>
<td width="53%">
</td>
<td width="35%">
</td>
</tr>
<tr valign="top">
<td>
</td>
<td>
<h1>
Frequent Flyer Program</h1>
</td>
</tr>
<tr valign="top">
<td>
</td>
<td>
<h2>
Returning Members</h2>
</td>
</tr>
<tr valign="top">
<td>
</td>
<td>
<form id="loginForm" runat="server">
<div>
<asp:TextBox id="account" runat="server"/>
<asp:TextBox id="password" runat="server"/>
<asp:Label id="badLogin" runat="server"/>
</div>
</form>
<h2>
New Members</h2>
<p>
<a href="Registration.aspx">E
</p>
</td>
<td>
<div class="c3">
<table width="168" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="images/spic_001.jpg" width="168" height="209" alt="Visual formatting image" />
</td>
</tr>
<tr>
<td height="30" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cellbackhmright">
<tr>
<td width="100%" height="50" bgcolor="#DADADA" class="whiteline">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td class="promotext">
New Frequent Flyer members can now earn 2,000 Bonus Miles for taking their first
flight.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr valign="top">
<td height="30">
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF" class="btmmenu">
</td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF" class="btmmenu">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="12%">
</td>
<td width="76%" class="btmmenu">
<a href="index.htm">Home</a> | Frequent Flyers<br />
© 2010 Skyward Airlines
</td>
<td width="12%">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF" class="btmmenu">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
</p>
<p>
</p>
<p>
</p>
</body>
</html>
I have tried to solve this on my own. I am using this page from the text to develop this program. The variable curUser is not a global variable. I cannot figure out why I am getting this error.
curUser.Read---0002.pdf
ASKER
this is how curUser is used. I hope this clears things up a bit.
SkywardAviation.zip
SkywardAviation.zip
what do you intend to do here, you need to declare curUser, it has to be some type.
What do you want it to be....
What do you want it to be....
ASKER
How do I declare it with the read(). I tried to declare it so that I can get rid of the errors. Now, you see what I am saying the book has it exactly like that? No declaration. I do not know how to declare it. I get a little confused when I am doing a step by step program and there are major parts missing. I am suppose to be learning at this point then I have to put everything that I learned into the project at the end of the chapter. Thank you. tommyboy was trying to get me to see that and I did.
curUser.Read---0002.pdf
curUser.Read---0002.pdf
i think this flier id is to be fetched from database and stored in session.
I suppose the curUser is DataReader, try to follow the example given by me in my first post....
I suppose the curUser is DataReader, try to follow the example given by me in my first post....
ASKER
Error 133 No overload for method 'FetchFlyerId' takes '0' arguments C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S kywardAvia tion\Login .aspx.cs 13 9 C:\...\SkywardAviation\
Error 134 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S kywardAvia tion\Login .aspx.cs 26 17 C:\...\SkywardAviation\
Error 135 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S kywardAvia tion\Login .aspx.cs 28 21 C:\...\SkywardAviation\
Error 136 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S kywardAvia tion\Login .aspx.cs 30 42 C:\...\SkywardAviation\
Error 137 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S kywardAvia tion\Login .aspx.cs 33 13 C:\...\SkywardAviation\
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
public void Page_Load()
{
FetchFlyerId();
}
void FetchFlyerId(SqlConnection connection)
{
using (connection)
{
SqlCommand command = new SqlCommand(
"SELECT FlyerID, FlyerName FROM ;",
connection);
connection.Open();
SqlDataReader curUser = command.ExecuteReader();
if (reader.HasRows)
{
if (reader.Read())
{
Session["FlyerId"] = reader("FlyerID");
}
}
reader.Close();
}
}
}
these are the errors to this change. No go.
Error 134 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S
Error 135 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S
Error 136 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S
Error 137 The name 'reader' does not exist in the current context C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\S
using System;
using System.Collections.Generic
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
public void Page_Load()
{
FetchFlyerId();
}
void FetchFlyerId(SqlConnection
{
using (connection)
{
SqlCommand command = new SqlCommand(
"SELECT FlyerID, FlyerName FROM ;",
connection);
connection.Open();
SqlDataReader curUser = command.ExecuteReader();
if (reader.HasRows)
{
if (reader.Read())
{
Session["FlyerId"] = reader("FlyerID");
}
}
reader.Close();
}
}
}
these are the errors to this change. No go.
i would suggest you try to learn basics of c#, it seems that you are not even aware of how to call a function...
A Bit Too much to handle here for me to help you come out of this....
Things can't work if we just read some pdf and try to copy the content into a c# program.
A Bit Too much to handle here for me to help you come out of this....
Things can't work if we just read some pdf and try to copy the content into a c# program.
ASKER
I am sorry but I used the code you gave me. I do know how to call a function. I did not copy from a pdf. I am using a book. Please let someone else help if there is a problem.
Hi, this is because you have not define curUser
So the compiler doesn't know what is this ???
I have searched in your project.. there is no reference for curUser. So no one can even compiler tell you what is that.
Just add reference for this variable or declare it. It could be some object for some class.
One more thing....
You may have left one chapter or Topic while studying. That's why you are getting Error which is unknown for you. It may depend on previous topic.
This is happened because in this type of course or study we can always neglect some part of Study.....
So the compiler doesn't know what is this ???
I have searched in your project.. there is no reference for curUser. So no one can even compiler tell you what is that.
Just add reference for this variable or declare it. It could be some object for some class.
One more thing....
You may have left one chapter or Topic while studying. That's why you are getting Error which is unknown for you. It may depend on previous topic.
This is happened because in this type of course or study we can always neglect some part of Study.....
ASKER
No, I have gone page by page. this is not a very good book as you have found out. I told you that there was not a reference to the curUser. I have gone page by page. Sometime it is good to have examples to compare. Now, I tried to declare the curUser.Reader()
So how do I declare it. I used the int curUser; and string curUser; I got errors for days. If you go back to the pages I have copied this is a step by step project and it should have been explained. This is the learning process not the project per se. So, I do believe that part of the curUser should have been explained. Also, I googled it and I did not find an answer to this problem. It appears that you may have some difficulty with this issue because no one has been able to show how to do it, yet!
So how do I declare it. I used the int curUser; and string curUser; I got errors for days. If you go back to the pages I have copied this is a step by step project and it should have been explained. This is the learning process not the project per se. So, I do believe that part of the curUser should have been explained. Also, I googled it and I did not find an answer to this problem. It appears that you may have some difficulty with this issue because no one has been able to show how to do it, yet!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got the answer I need from tommyBoy. I made a mistake and deleted a large portion of my code. So, I did my error and added the code I need. Thanks your answer is correct however.
ASKER
Thanks.
Open in new window
Make sure you replace the query with the correct query....