[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

namespace 'textUsername'

Posted on 2009-04-29
8
Medium Priority
?
397 Views
Last Modified: 2013-12-14
I am getting the following error message...

The namespace 'textUsername' does not exist indexer the current context....

What does this mean and how can if fix it?
register.aspx...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register" %>
 
<!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 runat="server">
    <title>Register for FREE Today!!!! </title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Please enter in your login infomation:<br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="User Name: "></asp:Label>
        <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox><br />
        <asp:Label ID="Label2" runat="server" Text="Password: "></asp:Label>
        <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox><br />
        <br />
        <asp:Button ID="ButtonLogin" runat="server" Text="Login" OnClick="ButtonLogin_Click" />
        <asp:Button ID="ButtonRegister" runat="server" Text="Register" OnClick="ButtonRegister_Click" /><br />
        <br />
        <asp:Label ID="lblException" runat="server"></asp:Label></div>
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:texans
  • 4
  • 3
8 Comments
 

Author Comment

by:texans
ID: 24260705

register.aspx.cs...
 
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
 
public partial class register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void ButtonRegister_Click(object sender, EventArgs e)
    {
        string uname = txtUsername.Text;
        string pwd = txtPassword.Text;
        try
        {
            string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
            strConnection += "Data Source=" + Server.MapPath("Database.accdb");
 
            // Open the connection and set the command
            OleDbConnection objConnection = new OleDbConnection(strConnection);
 
            //String strSQL = "INSERT INTO UHCL_Student (Uname, Pwd) VALUES('Bob', 'Martin');";
 
            String strSQL = "INSERT INTO UHCL_Student (Uname, Pwd) VALUES('" + uname + "', '" + pwd + "');";
            OleDbCommand cmd = new OleDbCommand(strSQL, objConnection);
            objConnection.Open();
            int no = cmd.ExecuteNonQuery();
            objConnection.Close();
        }
        catch (Exception excep)
        {
            //throw excep;
            lblException.Text = excep.Message;
        }
    }
    protected void ButtonLogin_Click(object sender, EventArgs e)
    {
        string uname = txtUsername.Text;
        string pwd = txtPassword.Text;
        
        string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
        strConnection += "Data Source=" + Server.MapPath("Student.mdb");
 
        // Open the connection and set the command
        OleDbConnection objConnection = new OleDbConnection(strConnection);
 
        string strSQL = "SELECT Uname,Pwd FROM UHCL_Student " +
            "WHERE Uname = '" + uname + "'";
        OleDbCommand cmd = new OleDbCommand(strSQL, objConnection);
        objConnection.Open();
        OleDbDataReader objDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        if (objDataReader.Read() == true)
        {
            String uname_db = (String)objDataReader["Uname"];
            Response.Redirect("welcome.aspx");
        }
        else
        {
            lblException.Text = "User does not exist";
        }
        objDataReader.Close();
 
    }
}

Open in new window

0
 
LVL 15

Expert Comment

by:oobayly
ID: 24261190
At which line does the error occur? I'm guessing line #23 & #49.
Strangely enough, the page compiles and loads fine for me.
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24261213
can u share the complete error message
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:texans
ID: 24261250
Please see attachment!!!
errors.jpg
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24261369
Do these errors occur when you attempt to rebuild the project?
0
 

Author Comment

by:texans
ID: 24261400
Yes
0
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 total points
ID: 24261643
I honestly don't get it, the code compiled perfectly for me. This is going to sound stupid, but can you try excluding the register form from the project. Create a new form called register and completely overwrite the code in the page & code behind files with the code you've given us. That's exactly what I did.
0
 

Author Comment

by:texans
ID: 24262059
well that did it... but now when you go click on register, its given me this error...

Unrecognized database format 'C:\Users\user_name\Desktop\WebApplication1\WebApplication1\Database.accdb'.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question