Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- C#
- Redirect
- 자바
- 안드로이드
- TextBox
- Apache Lucene
- decompiler
- SpringSource Tool Suite
- 웹 서비스
- Eclipse
- Java
- scrollView
- 자바스크립트
- MS-SQL
- 컬럼명
- 이클립스
- asp.net
- html
- javascript
- WebView
- 웹뷰
- STS
- Android
- varags
- Web Service
- Bootstrap
- MANTIS
- MSsql
- jsp
- Maven
Archives
- Today
- Total
bboks.net™
C# 트랜잭션 처리 본문
public void TransactionExample() { private const string CONNECT_STR = "server=server_ip;database=db_name;user id=user_id;password=password;"; private SqlConnection con = new SqlConnection(CONNECT_STR);; private SqlCommand cmd = new SqlCommand(); command.Connection = con; try { con.Open(); //트랜잭션 시작 cmd.Transaction = cmd.Connection.BeginTransaction(); //쿼리 지정 cmd.CommandText = "Update ... SET ...."; cmd.Parameters.Clear(); //쿼리 실행 cmd.ExecuteNonQuery(); //트랜잭션 Commit cmd.Transaction.Commit(); } catch (Exception ex) { if (cmd.Transaction != null) { //오류 발생시 Rollback cmd.Transaction.Rollback(); } Console.WriteLine("ERROR : " + ex.Source + " - " + ex.Message); } }