Reputation: 1
my sign up works fine, but im trying to log in to my website, it used to work before but i edited a few things and now it keeps giving me that error. the only thing i changed was that i removed the creditcard names and values because i wont need to use them, so now my userclass doesnt contain a cvv, credit card type, credit number, city, street address.
my code is:
<asp:Panel ID="loginpan" Visible="false" runat="server" BackColor="Black" BorderColor="White" BorderStyle="Double" Style="height: 125px; margin-left: 728px; width: 415px; margin-top: -10px; position:absolute;">
<table style="height: 125px">
<tr>
<td>
<asp:Label ID="lblemail" runat="server" Text="E-Mail:" ForeColor="White"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtemail" runat="server" Width="326px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblpass" runat="server" Text="Password:" ForeColor="White"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtpass" runat="server" Width="327px" TextMode="Password"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnsignin" runat="server" CausesValidation="False" Text="Login" CssClass="TopBtns"
OnClick="btnsignin_Click" OnClientClick="return validate();" />
<asp:Button ID="forgotpass" runat="server" CausesValidation="False" Text="Forgot Password?" PostBackUrl="~/SiteForms/ForgotPass.aspx" CssClass="TopBtns" />
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Label ID="lblinfo" runat="server" Visible="true" ForeColor="White"></asp:Label>
</td>
</tr>
in the code behind:
UserClass userobj = new UserClass();
string email = txtemail.Text;
string pass = txtpass.Text;
userobj.UserEmailId = email;
userobj.UserPassword = pass;
if (userobj.UserExist())
{
Session["userobj"] = userobj;
if(Session ["FP"] == null)
Response.Redirect(Request.RawUrl);
Response.Redirect("~/SiteForms/Homepage.aspx");
}
else
{
if (userobj.UserExistSignUp() == false)
lblinfo.Text = " the email you inputted is not registered";
else
lblinfo.Text = " the password you inputted is wrong";
lblinfo.Visible = true;
}
}
the error that they give me is : No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.
Source Error:
Line 36: OleDbDataAdapter daObj = new OleDbDataAdapter(sqlString, conObj);
Line 37: DataSet dsUser = new DataSet();
Line 38: daObj.Fill(dsUser);
Line 39: DataTable dt = dsUser.Tables[0];
Line 40: conObj.Close();
and they highlight the daObj.Fill(dsUser); so i thought itd be from my userclass and dbfunctions, but i didnt change anything in them.
my userclass:
private string userEmailId;
public string UserEmailId
{
get { return userEmailId; }
set { this.userEmailId = value; }
}
private string userPassword;
public string UserPassword
{
get { return userPassword; }
set { this.userPassword = value; }
}
private string userFirstName;
public string UserFirstName
{
get { return userFirstName; }
set { this.userFirstName = value; }
}
private string userLastName;
public string UserLastName
{
get { return userLastName; }
set { this.userLastName = value; }
}
// =========================================================================
public bool UserExist()
{
string userSqlStr = "select [userPassword] from [UserTable] where [userPassword]='" +
this.UserPassword + "' and [eMailAddress]='" + this.userEmailId + "'";
DataTable dt = DBFunctions.SelectFromTable(userSqlStr, "DataBase.accdb");
if (dt.Rows.Count > 0)
return true;
return false;
}
public bool UserExistSignUp()
{
string userSqlStr = "select [eMailAddress] from [UserTable] where [eMailAddress]='" + this.userEmailId + "'";
DataTable dt = DBFunctions.SelectFromTable(userSqlStr, "DataBase.accdb");
if (dt.Rows.Count > 0)
return true;
return false;
}
and my dbfunction is
public static OleDbConnection GenerateConnection(string dbFileName)
{
OleDbConnection conObj = new OleDbConnection();
conObj.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + HttpContext.Current.Server.MapPath("~/App_Data/" + dbFileName) + ";Persist Security Info=False";
conObj.Open();
return conObj;
}
public static DataTable SelectFromTable(string sqlString, string dbFileName)
{
OleDbConnection conObj = GenerateConnection(dbFileName);
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = sqlString;
cmd.Connection = conObj;
OleDbDataAdapter daObj = new OleDbDataAdapter(sqlString, conObj);
DataSet dsUser = new DataSet();
daObj.Fill(dsUser);
DataTable dt = dsUser.Tables[0];
conObj.Close();
return dt;
}
Upvotes: 0
Views: 51
Reputation: 1
The problem ended up being with something in UserClass, so I deleted it and rewrote it exactly the same way and it worked.
the problem was probably from the web developer itself not understanding that something was deleted.
Upvotes: 0