C Sharp语言执行SQL语句的方法

2025-04-24 04:41:47

1、 public static bool sqlExecute鲍伊酷雪NonQuery(string strSql) //执行SQL语句方法,并且无返回值 撑俯擂摔{ if (m_dbTransaction == null) { connectionOpen(); //如果没有事务,则首先打开数据库连接 } try { m_dbCommand.CommandText = strSql; m_dbCommand.CommandType = CommandType.Text; m_dbCommand.ExecuteNonQuery(); //执行SQL语句 return true; } catch (Exception ex) { WriteLog.WriteSQLErrorLog("OracleDBAccess", "sqlExecuteNonQuery", strSql, ex.Message); throw ex;//抛出异常 } finally { if (m_dbTransaction == null) { connectionClose();//关闭数据库连接 } } }

C Sharp语言执行SQL语句的方法
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢