Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
//public string  qry_getUserRights(int i_DpIntID, int i_GroupID, string Module_Name)
    //{
    //    StringBuilder strBuilder = new StringBuilder();
    //    strBuilder.Append(" SELECT A.UI_ACCESS, A.UI_ADD, A.UI_EDIT, A.UI_VIEW, C.MVIEW, C.MADD, C.MEDIT, C.MACCESS ");
    //    strBuilder.Append(" FROM DPSECURE_UI A, DPSECURE_UI_DPLIST D, USER_RIGHTS_MASTER B, USER_RIGHTS_MASTER_DETAIL C ");
    //    strBuilder.Append(" WHERE A.ID = D.DPSECURE_UI_ID AND ");
    //    strBuilder.Append(" D.ID = C.DPSECURE_UI_DPLIST_ID AND ");
    //    strBuilder.Append(" B.ID = C.USER_RIGHTS_MASTER_ID AND ");
    //    strBuilder.Append(" A.UI_MENU_NAME =:Module_Name AND ");
    //    strBuilder.Append(" B.GROUP_ID =:i_GroupID  AND D.DP_LIST_ID =:i_DpIntID ");

    //    s_dsnstr = o_Cls_Utility.utl_fnGetDSNStr(SessionCheck.s_sessiondpid);
    //    OracleConnect o_Cls_OracleConnect = new OracleConnect(s_dsnstr);
    //    o_Cls_OracleConnect.OracleCommand_PreInit(strBuilder.ToString());

    //    o_Cls_OracleConnect.Parameter_String("Module_Name", Module_Name);
    //    o_Cls_OracleConnect.Parameter_Int32("i_GroupID", i_GroupID);
    //    o_Cls_OracleConnect.Parameter_Int32("i_DpIntID", i_DpIntID);

        
           
    //    return strBuilder.ToString();
    //}

 public void UserRights_Details(string Module_Name, string eximorform, Page t_Page, string SelMode)
        {
            string sql;
            User_Rigths_Qry o_Qry_UserRights = new User_Rigths_Qry();
            sql = o_Qry_UserRights.qry_getUserRights(SessionCheck.s_sessiondpintind, SessionCheck.s_sessionusergroupid, Module_Name);
            DataSet ds;
            StringBuilder str = new StringBuilder();
            s_DSNSTR = utl_fnGetDSNStr(SessionCheck.s_sessiondpid);
            OledbConnect obj_oc = new OledbConnect(s_DSNSTR);
            ds = obj_oc.GetDataSet(s_DSNSTR, sql);

            Control myCtlUTL = default(Control);
            tmp_Ctr = "ctl00$MainContent$";

            if (ds.Tables[0].Rows.Count == 0)
            {
                StringBuilder strBuilder = new StringBuilder();
                strBuilder = new StringBuilder();
                strBuilder.Append("<script language='javascript'>");
                strBuilder.Append("alert('Kindly provide rights to access the module !!!');");
                strBuilder.Append("window.location.href='../Admin/dpsecure.aspx'");
                strBuilder.Append("</script>");
                t_Page.RegisterStartupScript("LastLoginAccessForm", strBuilder.ToString());
                strBuilder = null;
            }
            else
            {
                if (eximorform == "E")
                {
                    if (ds.Tables[0].Rows[0]["UI_VIEW"].ToString() == "T")
                    {
                        if (ds.Tables[0].Rows[0]["MVIEW"].ToString() == "F")
                        {
                            myCtlUTL = t_Page.FindControl(tmp_Ctr + "SearchImageBtn");
                            ((Button)myCtlUTL).Visible = false;

                            myCtlUTL = t_Page.FindControl(tmp_Ctr + "SearchLbl");
                            ((Label)myCtlUTL).Visible = true;
                            ((Label)myCtlUTL).Text = "No View Rights !!!";
                        }
                    }

If i write above query it gives exception near
ASM
ds = obj_oc.GetDataSet(s_DSNSTR, sql);

all vaiables not bound.
Posted
Updated 2-Aug-13 2:05am
v2

1 solution

Not sure I'm reading the code correctly--I guess that the commented code is actually in use, called by this line
C#
sql = o_Qry_UserRights.qry_getUserRights(SessionCheck.s_sessiondpintind, SessionCheck.s_sessionusergroupid, Module_Name);

What is the OracleConnect class? I'd guess you're not using it correctly to set the parameters. Are you sure there are methods in that class named Parameter_String and Parameter_Int32 that take the name of a parameter and its value and *add* a parameter to something like an OracleCommand object?

All that's beyond the point, however, because even presuming that your OracleConnect class is creating a command object and that the parameter methods work correctly, you're calling that method while you build a SQL string, and then promptly disposing of your instance of OracleConnect and whatever command object it's created. All you pass back from qry_getUserRights is the SQL string, so all your parameters are lost.

By the way, why are you using OracleConnect to get your SQL string, and then OledbConnect to actually execute it (and is OledbConnect another custom class)? Is this really Oracle?

Using Oracle.DataAccess.dll (an Oracle library), I'd do something like this, which assumes an array of parameters and includes a count of items to include in the parameters (code quickly converted from VB, so might not be completely accurate):
C#
OracleConnection conn = New OracleConnection(connectString);
OracleCommand cmd = New OracleCommand(sql, conn);
cmd.Connection.Open();
if (myParams != null && myParams.Length > 0)
{
    cmd.ArrayBindCount = recordCount;
    for (int i = 0; i < myParams.Length; i++)
    {
        cmd.Parameters.Add(myParams[i]);
    }
}
OracleDataReader r = cmd.ExecuteReader();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900