Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

help with c#.net log in webform using ms access

tricket_7tricket_7 Posts: 3Member
I am trying to build a simple login form on an existing website I am getting these errors:
txtUser does not exist in the current context
txtPass does not exist in the current context
Literal1 does not exist in the current context

I will paste below first the form, then the codebehind

form
[code]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="logIn.aspx.cs" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Page




New users can register here.




















Please Login

















[/code]

Codebehind
[code]
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;


namespace WebApplication1
{


public partial class _logIn : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnLogin_Click(object sender, EventArgs e)
{


string connect = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Users\Christie\Desktop\WebApplication1\App_Data\prosearchusers.mdb";
string query = "Select Count(*) From tblCustRecords Where username = '" & txtUser & "' And [password] = '" & txtPass & "'";
int result = 0;
using (OleDbConnection conn = new OleDbConnection(connect))
{
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
cmd.Parameters.AddWithValue("Cust_Name", txtUser);
cmd.Parameters.AddWithValue("Cust_Password", txtPass);
conn.Open();
Session["User"] = txtUser;
result = (int)cmd.ExecuteScalar();
}
}
if (result > 0)
{
Response.Redirect("LoggedIn.aspx");
}
else
{
Literal1 = "Invalid login";
}

}
}
}
[/code]

Can someone please help me, I really do not have much experience in .net programming
Sign In or Register to comment.