I am doing a school project . Please help:
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.SqlClient;
using System.Web.Configuration;
using System.Data.SqlTypes;
namespace zephyrAir2
{
public partial class logIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Declaring variables for login controls and setting each to nothing
string username = null;
string pwd = null;
string pName = null;
username = Login1.UserName;
pwd = Login1.Password;
pName = "";
//Declaring connection string
string strConn = null;
// strConn = WebConfigurationManager.ConnectionStrings("ConnectionASPX").ConnectionString;
//* Setting a database path to the database
strConn = Server.MapPath("Data Source = tblsZephyrAir.mdb");
// * Declare and instantiate the SqlConnection
// * The SqlConnection object instantiated below uses a constructor with a single argument of type string.
// * This argument is called a connection string.
SqlConnection Conn = new SqlConnection(strConn);
//Opening connection
Conn.Open();
// *Setting Username as nothing and database query to search for the username and password
string sqlUsername = null;
sqlUsername = "SELECT Username,Password FROM UserAccounts ";
sqlUsername += " WHERE (Username = @Username";
sqlUsername += " AND Password = @Password)";
SqlCommand com = new SqlCommand(sqlUsername, Conn);
com.Parameters.AddWithValue("@Username", username);
com.Parameters.AddWithValue("@Password", pwd);
string Currentname = null;
Currentname = Convert.ToString(com.ExecuteScalar());
if (!string.IsNullOrEmpty(Currentname))
{
Session["UserAuthentication"] = username;
Response.Redirect("ZephyrIndex.aspx");
}
else
{
Session["UserAuthentication"] = "";
}
}
}
}
I am trying to have the user log in using a tblsZephyrAir.mdb database I created and have them redirected to the ZephyrIndex.aspx page which is the Home Page in other words. It says" ArgumentException was unhandled by user code. "
It also says " Keyword not supported: 'c:\users\userpcone\downloads\zephyrair2\zephyrair2\data source'."