求高手帮忙~万分感谢!!!!
需要c# + Oracle 的windows系统,只要有查询,增加,删除,报表打印功能就可以,谢谢各位大哥了!~~ QQ:80515186 Email:wangshunzhi@
using System; using System.Collections.Generic; using System.Text; using System.Configuration; using System.Data.OracleClient; using System.Data; using System.Windows.Forms; using System.Collections; using Microsoft.VisualBasic.Devices; using System.Security.Cryptography; using pupu { class DBProc { protected string _connStr = string.Empty; public DBProc() { //以下自己填写 string _dataSouce = ""; //数据库名 string _user =""; //登陆用户名 string _pw=""; //登录密码 //这你自己填写 _connStr = "Data Source=" + _dataSouce + ";Persist Security Info=True;User ID=" + _user + ";Password=" + _pw + ";Unicode=True"; } public string GetConnectionstring() { return _connStr; } public DataTable OraExeFill(string cmdStr) { DataTable _returnTable = new DataTable(); OracleConnection _connection = new OracleConnection(GetConnectionstring()); try { OracleCommand _command = _connection.CreateCommand(); _ = cmdStr; OracleDataAdapter _adapter = new OracleDataAdapter(cmdStr, _connection); _adapter.Fill(_returnTable); } catch (Exception) { } return _returnTable; } public bool OraExeNonQuery(string cmdStr, ref string msg) { bool _ret = false; OracleConnection _connection = new OracleConnection(GetConnectionstring()); try { _connection.Open(); OracleTransaction _trans = _connection.BeginTransaction(); OracleCommand _command = _connection.CreateCommand(); _command.Transaction = _trans; try { _ = cmdStr; _command.ExecuteNonQuery(); _(); _ret = true; } catch (Exception ex1) { _trans.Rollback(); msg = ex1.Message.ToString(); } } catch (Exception ex) { msg = ex.Message.ToString(); } finally { _connection.Close(); } return _ret; } } }查询按钮的点击事件:
DBProc d = new DBProc(); DataTable dt = new DataTable(); string cmdstr = "select * from tableName"; dt = d.OraExeFill(cmdstr); gridView.DataSouse = dt; gridView.Bind();删除按钮的点击事件:
DBProc d = new DBProc(); string mes = ""; string cmdstr = "delete from tableName where 条件"; bool b = d.OraExeNonQuery(cmdstr,ref mes); if(b) MessageBox.Show("删除成功"); else MessageBox.Show("删除失败"); //调用下查询按钮的事件重新查询增加按钮的点击事件与删除按钮基本相同,把查询语句改了就OK