c# 데이터베이스와 연동해서 데이터처리하는 부분 질문이요ㅠㅠ
글쓴이: omsminsun / 작성시간: 일, 2013/05/26 - 9:46오후
private void set_date() { bool read; int db_date; string db_date_1; int result; string now_date_1 = DateTime.Now.ToString("yyyyMMdd"); int now_date = Convert.ToInt32(now_date_1); string select_sql = "select releaseDate from DVD"; string update_sql; Conn = new SqlConnection(strConn); Conn.Open(); Comm = new SqlCommand(select_sql); Comm.Connection = Conn; Read = Comm.ExecuteReader(); while (Read.Read()) { db_date_1 = Read["releaseDate"].ToString(); db_date = Convert.ToInt32(db_date_1); // Comm1.Parameters.Clear(); result = now_date - db_date; if (result > 100) { Read.Close(); Read.Dispose(); // Comm.Close(); Comm.Dispose(); // rel_string = "구프로"; update_sql = "update DVD set newOldInfo='old'"; Comm = new SqlCommand(update_sql); Comm.Connection = Conn; Read = Comm.ExecuteReader(); } else { Read.Close(); Read.Dispose(); // Comm.Close(); Comm.Dispose(); // rel_string = "구프로"; update_sql = "update DVD set newOldInfo='new'"; Comm = new SqlCommand(update_sql); Comm.Connection = Conn; Read = Comm.ExecuteReader(); } } Conn.Close();
현재 시간과 데이터베이스에 입력 된 시간의 차이값에 따라 데이터베이스의 값을 수정해주는 함수인데요.
하나의 결과값이 모든 데이터베이스에 적용이 되네요ㅠㅠ
(예를 들면 데이터베이스의 첫 행의 결과값이 4인경우 모든 데이터베이스의 newOldInfo가 new로 설정이 돼요ㅠㅠ)
도대체 어디가 문제일까요ㅠㅠ?
Forums:
댓글 달기