我想知道我是否可以获得一些帮助,因为我正在处理的某些代码出错!
点击我的登录按钮时,我在第37行得到以下信息: "没有给出一个或多个必需参数的值。
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Data.OleDb.OleDbException:没有为一个或多个必需参数指定值。"
有什么想法吗?
非常感谢
由于
杰克! :)
protected void btnLogin_Click(object sender,EventArgs e) {
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["CameraWarehouseDB"].ConnectionString);
//Opens connection with database
conn.Open();
//Declared a string - checks to see if username already exisits in the database.
string checkusername = "SELECT COUNT (*) FROM [Customer] WHERE CustomerUserName= '" + txtUserName.Text + "'";
//If count is 1, it means its already exisits, so cannot be used again and triggers alert
OleDbCommand com = new OleDbCommand(checkusername, conn);
//Replace removes any spaces the user make have accidentally inputed in the text box
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
conn.Close();
if (temp == 1)
{
//Verying username and password - Checks for password in database based on entered username
conn.Open();
string checkpassword = "SELECT Password FROM [Customer] WHERE CustomerUserName= '" + txtUserName.Text + "'";
OleDbCommand passwordcom = new OleDbCommand(checkpassword, conn);
string password = passwordcom.ExecuteScalar().ToString();
//Verify password based on entered password in password text box
if (password == txtPassword.Text)
{
Session["New"]=txtUserName.Text;
Response.Write("Password is correct");
}
else
{
Response.Write("Incorrect password entered, please try again");
}
}
else
{
Response.Write("Incorrect user name entered, please try again");
}
conn.Close();
}
}