惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Y
Y Combinator Blog
T
Tailwind CSS Blog
G
Google Developers Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
爱范儿
爱范儿
博客园 - 【当耐特】
腾讯CDC
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
博客园_首页
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - 狂闪工作室

Subject类 Questions类 Products类 Members类 Member类 Info类 Images类 Dlh21数据库备份 文章集萃 网站方案 网址收集 TreeView小结 仿照csdn左面的菜单的ASP+数据库无限级树菜单代码分享 树型论坛的快速算法 [原创]用ASP.NETN层结构封装的数据层访问基类 如何在DataGrid前加一个列让其id按顺序排列,而非绑定的id字段的乱七八糟的排序??? 如何把两个并列文本框整合到一个下拉框中? 图片上传自动生成缩略图VB组件!
Category类
狂闪工作室 · 2005-09-15 · via 博客园 - 狂闪工作室

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace Db
{
 /// <summary>
 /// Category 的摘要说明。
 /// </summary>
 public class Category
 {
  public Category()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }

  private SqlConnection conn;
  private SqlCommand cmd;
  private SqlDataReader dr;
  private DataSet ds;
  private SqlDataAdapter da;
  
  public void addCategory(ArrayList a)
  {
   conn = new SqlConnection(Str.con);
   cmd = new SqlCommand("Category_add",conn);
   cmd.CommandType = CommandType.StoredProcedure;

   cmd.Parameters.Add("@OrderID",SqlDbType.VarChar,50).Value = a[0];
   cmd.Parameters.Add("@DeepID",SqlDbType.VarChar,50).Value = a[1];
   cmd.Parameters.Add("@Category",SqlDbType.VarChar,50).Value = a[2];
   cmd.Parameters.Add("@FatherID",SqlDbType.VarChar,50).Value = a[3];

   conn.Open();
   try
   {
    cmd.ExecuteNonQuery();
   }
   catch(Exception ex)
   {
    throw new Exception(ex.Message);
   }
   finally
   {
    cmd.Dispose();
    conn.Close();
   }
  }

  public void updCategory(ArrayList a)
  {
   conn = new SqlConnection(Str.con);
   cmd = new SqlCommand("Category_updWhereID",conn);
   cmd.CommandType = CommandType.StoredProcedure;

   cmd.Parameters.Add("@OrderID",SqlDbType.VarChar,50).Value = a[0];
   cmd.Parameters.Add("@DeepID",SqlDbType.VarChar,50).Value = a[1];
   cmd.Parameters.Add("@Category",SqlDbType.VarChar,50).Value = a[2];
   cmd.Parameters.Add("@FatherID",SqlDbType.VarChar,50).Value = a[3];
   cmd.Parameters.Add("@ID",SqlDbType.Int).Value = a[4];

   conn.Open();
   try
   {
    cmd.ExecuteNonQuery();
   }
   catch(Exception ex)
   {
    throw new Exception(ex.Message);
   }
   finally
   {
    cmd.Dispose();
    conn.Close();
   }
  }

  public SqlDataReader drCategory()
  {
   conn = new SqlConnection(Str.con);
   cmd = new SqlCommand("Category_sel",conn);
   cmd.CommandType = CommandType.StoredProcedure;

   conn.Open();
   dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
   return dr;
  }

  public SqlDataReader drCategoryWhereFatherID(string a)
  {
   conn = new SqlConnection(Str.con);
   cmd = new SqlCommand("Category_selWhereFatherID",conn);
   cmd.CommandType = CommandType.StoredProcedure;

   cmd.Parameters.Add("@FatherID",SqlDbType.VarChar,50).Value = a.ToString();

   conn.Open();
   dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
   return dr;
  }

  public DataSet dsCategory()
  {
   conn = new SqlConnection(Str.con);
   da = new SqlDataAdapter();
   da.SelectCommand = new SqlCommand("Category_sel",conn);
   da.SelectCommand.CommandType = CommandType.StoredProcedure;

   conn.Open();
   try
   {
    ds = new DataSet();
    da.Fill(ds);
    return ds;
   }
   catch(Exception ex)
   {
    throw new Exception(ex.Message);
   }
   finally
   {
    da.SelectCommand.Dispose();
    conn.Close();
   }
  }


  public SqlDataReader drWhereOrderID(string a)
  {
   conn = new SqlConnection(Str.con);
   cmd = new SqlCommand("Category_selWhereOrderID",conn);
   cmd.CommandType = CommandType.StoredProcedure;

   cmd.Parameters.Add("@OrderID",SqlDbType.VarChar,50).Value = a.ToString();

   conn.Open();
   dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
   return dr;
  }
 }
}