首页 > 代码库 > C# OracleParameter 执行增删改查 实例

C# OracleParameter 执行增删改查 实例

 

 

public static Boolean getLmt(string lmtd_name)
    {
        string usr_user = HttpContext.Current.Session["MJERP10username"].ToString();
        if (lmtd_name == "") { return true; }
        //string sql = @"select id from sys_lmtd where lmtd_mde||‘_‘||lmtd_name=‘" + lmtd_name + "‘ and lmtd_username=‘" + usr_user + "‘ union all select ro.id from role_mstr ro join usr_mstr on usr_role_id = ro.id where usr_user = ‘" + usr_user + "‘";

        string sql1 = @"select id from sys_lmtd where lmtd_mde||‘_‘||lmtd_name=:lmtd_name and lmtd_username=:lmtd_username union all select ro.id from role_mstr ro join usr_mstr on usr_role_id = ro.id where usr_user =:usr_user";

        OracleParameter[] param = new OracleParameter[]{
            new OracleParameter(":lmtd_name",OracleType.VarChar,50),  
            new OracleParameter(":lmtd_username",OracleType.VarChar,50), 
            new OracleParameter(":usr_user",OracleType.VarChar,30)
        };
        param[0].Value = http://www.mamicode.com/lmtd_name;"connString"]))
        {
            connection.Open();
            OracleCommand cmd = new OracleCommand(sql1,connection);
            for (int i = 0; i < param.Length; i++)
            {
                cmd.Parameters.Add(param[i]);
            }
            OracleDataAdapter myda = new OracleDataAdapter(cmd);
            myda.Fill(ds);
            connection.Close();
        }

        if (ds.Tables[0].Rows.Count > 0)
        {
            ds.Dispose();
            return true;
        }
        else
        {
            ds.Dispose();
            return false;
        }

    }

  

C# OracleParameter 执行增删改查 实例