Friday, April 18, 2008

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

Cause
Security permissions were not properly set when the Oracle 9i Release 2 client was installed on Windows with NTFS. The result of this is that content of the ORACLE_HOME directory is not visible to Authenticated Users on the machine; this again causes an error while the System.Data.OracleClient is communicating with the Oracle Connectivity software from an ASP.NET using Authenticated User privileges.
Solution
To fix the problem you have to give the Authenticated Users group privilege to the Oracle Home directory.

  1. Log on to Windwos as a user with Administrator privileges.
  2. Start Window Explorer and navigate to the ORACLE_HOME folder.
  3. Choose properties on the ORACLE_HOME folder.
  4. Click the "Security" tab of the "Properties" window.
  5. Click on "Authenticated Users" item in the "Name" list.
  6. Uncheck the "Read and Execute" box in the "Permissions" list under the "Allow" column.
  7. Re-check the "Read and Execute" box under the "Allow" column
  8. Click the "Advanced" button and in the "Permission Entries" verify that "Authenticated Users" are listed with permission = "Read & Execute", and Apply To = "This folder, subfolders and files". If not, edit that line and make sure that "Apply To" drop-down box is set to "This folder, subfolders and files". This should already be set properly but it is important that you verify it.
  9. Click the "Ok" button until you close out all of the security properties windows. The cursor may present the hour glass for a few seconds as it applies the permissions you just changed to all subfolders and files.
  10. Reboot, to assure that the changes have taken effect.

Thursday, April 17, 2008

Running a stored procedure from ASP dot net

Suppose there is a procedure
PROCEDURE PRC_VALIDATEUSER(usrName in VARCHAR,usrPwd in VARCHAR,
,usrValid out NUMBER) AS
BEGIN
/*…………*/
END;

Now in C# we write code the following way
Public Boolean validateUser(string pusrname,string pusrpass)
{
Try
{
OracleConnection con = new OracleConnection(appParams.connString);
//instead of appParams.connString use connection string for your database
con.Open();
sql = " begin validateuser(:uName,:uPasswd,:uValid); end;";
OracleParameter p1 = new OracleParameter();
p1.OracleType = OracleType.VarChar;
OracleParameter p2 = new OracleParameter();
p2.OracleType = OracleType.VarChar;
OracleParameter p3 = new OracleParameter();//dept
p3.OracleType = OracleType.Number;
p1.ParameterName = "uName";
p2.ParameterName = "uPasswd";
p3.ParameterName = "uValid";
p1.Value=pusrname;
p2.Value=pusrpass;
OracleCommand cmd = new OracleCommand(sql, con);
cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3);
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
if(p3.value==1)
return true;
else
return false;
}
Catch(System.exception ex)
{
return false;
}
}