2015-11-14 59 views
0

我的註冊工作正常,但即時通訊嘗試登錄到我的網站,它曾經工作過,但我編輯了幾件事情,現在它不斷給我這個錯誤。我唯一改變的是我刪除了信用卡名稱和值,因爲我不需要使用它們,所以現在我的用戶類不包含cvv,信用卡類型,信用卡號碼,城市,街道地址。沒有給出一個或多個必需參數的值。 daObj.Fill(dsUser);

我的代碼是:

<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>&nbsp;</td> 
       <td> 
        <asp:Button ID="btnsignin" runat="server" CausesValidation="False" Text="Login" CssClass="TopBtns" 
         OnClick="btnsignin_Click" OnClientClick="return validate();" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

      <asp:Button ID="forgotpass" runat="server" CausesValidation="False" Text="Forgot Password?" PostBackUrl="~/SiteForms/ForgotPass.aspx" CssClass="TopBtns" /> 
       </td> 
      </tr> 
      <tr> 
       <td>&nbsp;</td> 
       <td> 
        <asp:Label ID="lblinfo" runat="server" Visible="true" ForeColor="White"></asp:Label> 
       </td> 
      </tr> 
在後面的代碼

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; 
    } 
} 

,他們給我的錯誤是: 沒有爲一個或多個必需的參數給定值。

描述:執行當前Web請求期間發生未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。

異常詳細信息:System.Data.OleDb.OleDbException:未給出一個或多個必需參數的值。

源錯誤:

線36:OleDbDataAdapter的daObj =新OleDbDataAdapter的(的SqlString,conObj);

行37:DataSet dsUser = new DataSet();

第38行:daObj.Fill(dsUser);

第39行:DataTable dt = dsUser.Tables [0];

第40行:conObj.Close();

他們突出顯示了daObj.Fill(dsUser); 所以我認爲它是從我的用戶類和dbfunctions,但我沒有改變任何東西。

我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; 
} 

和我dbfunction是

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; 
} 
+0

你有沒有試過複製導致問題的'CommandText'並直接在Access中運行它?這樣做應該讓你更深入地瞭解發生了什麼問題。你確定你的字段名稱在你的查詢中拼寫正確嗎? – pstrjds

+0

** OMG **'「從[UserTable]中選擇[eMailAddress],其中[eMailAddress] ='」+ this.userEmailId +「'」;'**請閱讀:** https://en.wikipedia.org/wiki/SQL_injection –

+0

這僅僅是我的學校項目考試,所以任何人都可以入侵它並不重要。它不在線上。 – Jouwana

回答

0

的問題結束了在UserClass的東西之中,所以我刪除它,改寫它完全一樣的方式和它的工作。

這個問題可能來自web開發人員本身不理解的東西被刪除。

相關問題