我在asp中创建了一个登录表单,我似乎得到了这个错误:
Parameter @id has no default value. Description: An unhandled exception occurred during the execution of the >current web request. Please review the stack trace for more
有关>错误的信息以及它在代码中的起源。
Exception Details: System.Data.OleDb.OleDbException: Parameter @id has no >default value. Source Error: Line 18: }); Line 19: Line 20: OleDbDataReader reader = loginCommand.ExecuteReader(); Line 21: if (reader.Read()) Line 22: {
OleDbConnection connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Server.MapPath("\\App_Data\\talManager.mdb"));
connection.Open();
OleDbCommand loginCommand = new OleDbCommand();
loginCommand.Connection = connection;
loginCommand.CommandText = "SELECT [_fname], [_id], [_password] FROM
admins WHERE [_id] = @id AND [_password] = @password";
loginCommand.Parameters.AddRange(new OleDbParameter[]
{
new OleDbParameter("@id", Request.Form["id"]),
new OleDbParameter("@password", Request.Form["password"])
});
OleDbDataReader reader = loginCommand.ExecuteReader();
if (reader.Read())
{
Session["fname"] = reader["_fname"];
Session["id"] = reader["_id"];
Session["isAdmin"] = true;
} else
{
error.InnerText = "Invalid ID or password.";
}
reader.Close();
connection.Close();
任何帮助将不胜感激。提前谢谢!