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

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.

Howdy, Stranger!

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

Categories