namespace 'textUsername'

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

texansAsked:
Who is Participating?
 
oobaylyConnect With a Mentor Commented:
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
 
texansAuthor Commented:

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
 
oobaylyCommented:
At which line does the error occur? I'm guessing line #23 & #49.
Strangely enough, the page compiles and loads fine for me.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Anurag ThakurTechnical ManagerCommented:
can u share the complete error message
0
 
texansAuthor Commented:
Please see attachment!!!
errors.jpg
0
 
oobaylyCommented:
Do these errors occur when you attempt to rebuild the project?
0
 
texansAuthor Commented:
Yes
0
 
texansAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.