コード例 #1
0
 public static ArticleVO getArticleItem(string aIdx)
 {
     using (SqlConnection conn = DBConn.getConn())
     {
         conn.Open();
         ArticleVO articleItem = null;
         using (SqlCommand cmd = new SqlCommand())
         {
             cmd.Connection = conn;
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "P_ArticleItem_SELECT";
             cmd.Parameters.Add("@aIdx", System.Data.SqlDbType.NVarChar, 30);
             cmd.Parameters["@aIdx"].Value = aIdx;
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     articleItem = new ArticleVO
                     {
                         aIdx = reader["aIdx"].ToString(),
                         Title = reader["Title"].ToString(),
                         Indate = Convert.ToDateTime(reader["Indate"]),
                         Deleted = Convert.ToChar(reader["Deleted"])
                     };
                 }
             }
         }
         return articleItem;
     }
 }
コード例 #2
0
 public static ArrayList getArticleList(string searchText, string selecter, int page)
 {
     using (SqlConnection conn = DBConn.getConn())
     {
         conn.Open();
         var articleList = new ArrayList();
         using (SqlCommand cmd = new SqlCommand())
         {
             cmd.Connection = conn;
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "P_ArticleList_SELECT";
             cmd.Parameters.Add("@aIdx", System.Data.SqlDbType.NVarChar, 30);
             cmd.Parameters.Add("@searchText", System.Data.SqlDbType.NVarChar, 100);
             cmd.Parameters.Add("@title", System.Data.SqlDbType.VarChar, 30);
             cmd.Parameters.Add("@contents", System.Data.SqlDbType.VarChar, 30);
             cmd.Parameters.Add("@writer", System.Data.SqlDbType.VarChar, 30);
             cmd.Parameters.Add("@titleContents", System.Data.SqlDbType.VarChar, 30);
             cmd.Parameters.Add("@page", System.Data.SqlDbType.Int);
             cmd.Parameters["@aIdx"].Value = searchText;
             cmd.Parameters["@searchText"].Value = searchText;
             cmd.Parameters["@" + selecter].Value = selecter;
             cmd.Parameters["@page"].Value = page;
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     ArticleVO article = new ArticleVO
                     {
                         aIdx = reader["aIdx"].ToString(),
                         Title = reader["Title"].ToString(),
                         Indate = Convert.ToDateTime(reader["Indate"]),
                         Deleted = Convert.ToChar(reader["Deleted"]),
                         Contents = reader["Contents"].ToString()
                     };
                     articleList.Add(article);
                 }
             }
         }
         return articleList;
     }
 }