C# OracleParameter 执行增删改查 实例
Posted 苏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 = lmtd_name; param[1].Value = usr_user; param[2].Value = usr_user; DataSet ds = new DataSet(); using (OracleConnection connection = new OracleConnection(ConfigurationManager.AppSettings["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 执行增删改查 实例的主要内容,如果未能解决你的问题,请参考以下文章
在C#的控制台应用中使用Dapper链接MySQL并执行一些增删改查