问题描述
privatevoidbtnLogin_Click(objectsender,EventArgse){if(txtAdmin.Text.Trim()==""||txtPwd.Text.Trim()==""){MessageBox.Show("用户名和密码不能为空!","出错",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);}else{SysAdminadmin=newSysAdmin();admin.AdminID=txtAdmin.Text;admin.AdminPwd=txtPwd.Text;OracleDataReaderdr=admin.Login(admin);if(dr.Read()){MessageBox.Show("登录成功!");}}}publicOracleDataReaderLogin(SysAdminadmin){OracleDataReaderdr=null;stringstrSql="select*fromtb_userwhereadminID=@adminIDandadminPwd=@adminPwd";try{OracleParameter[]param={newOracleParameter("@adminID",OracleType.NVarChar,20),newOracleParameter("@adminPwd",OracleType.NVarChar,20)};param[0].Value=AdminID;param[1].Value=AdminPwd;dr=OraDB.ExecuteReader(strSql,param);returndr;}catch{throw;}finally{if(dr!=null)dr.Close();}}}publicstaticOracleDataReaderExecuteReader(stringSQLString,paramsOracleParameter[]Parms){OracleConnectionconnection=newOracleConnection(strConn);OracleCommandcmd=newOracleCommand();try{PrepareCommand(cmd,connection,null,SQLString,Parms);OracleDataReadermyReader=cmd.ExecuteReader(CommandBehavior.CloseConnection);cmd.Parameters.Clear();returnmyReader;}catch(System.Data.SqlClient.SqlExceptione){throwe;}}
解决方案
解决方案二:
Oracle的参数化是:冒号,不是@号,所以你上面要改成newOracleParameter(":adminID",OracleType.NVarChar,20),
解决方案三:
把@换成冒号
解决方案四:
stringstrSql="select*fromtb_userwhereadminID=@adminIDandadminPwd=@adminPwd";请问这句要改吗?
解决方案五:
当然要改……
解决方案六:
oracle的存储过程参数声明,没有@。大概这样的写法OracleParameter[]OraParams=newOracleParameter[1];OraParams[0]=newOracleParameter("adminID",OracleDbType.NVarChar,20);DataTabledt=db.GetRecord("select*fromtb_userwhereadminID=:adminID",OraParams);
解决方案七:
还是有错误,请指教
解决方案八:
还是这个错误,没有变化