日期:2014-05-17 浏览次数:20440 次
using (TransactionScope scope = new TransactionScope()) { bool aaa = InsertMySQLServer(); //插入我方的MS-SQL数据库 bool bbb = InsertSybaseServer(); //插入对方的Sybase数据库 if (aaa && bbb) { scope.Complete(); } }
OleDbConnection Conn = new OleDbConnection("Provider=Sybase.ASEOLEDBProvider;Srvr=ip,5000;Catalog=databasename;User Id=username;Password=password"); Conn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = Conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "myProcedure"; DataTable ds = new DataTable(); OleDbParameter menu = new OleDbParameter("menu", OleDbType.Char); menu.Direction = ParameterDirection.Input; menu.Value = "yltest888"; cmd.Parameters.Add(menu); //省略参数若干 OleDbParameter ret = new OleDbParameter("ret", OleDbType.Integer, 4); ret.Direction = ParameterDirection.ReturnValue; ret.Value = 0; cmd.Parameters.Add(ret); OleDbParameter msg = new OleDbParameter("msg", OleDbType.Char, 50); msg.Direction = ParameterDirection.ReturnValue; msg.Value = ""; cmd.Parameters.Add(msg); int result = cmd.ExecuteNonQuery(); string aaa = msg.Value.ToString(); string bbb = ret.Value.ToString();