c#에서 스토리지 프로세스 수행 방법
30132 단어 저장 프로세스
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10
11 namespace
12 {
13 using System.Data.SqlClient;
14 public partial class Form1 : Form
15 {
16 public Form1()
17 {
18 InitializeComponent();
19 }
20 string connStr = "Data Source=.;Initial Catalog=MySchoolMoreData;Integrated Security=True";
21
22 #region +void btnNoPARAMAS_Click(object sender, EventArgs e)
23 /// <summary>
24 ///
25 /// </summary>
26 /// <param name="sender"></param>
27 /// <param name="e"></param>
28 private void btnNoPARAMAS_Click(object sender, EventArgs e)
29 {
30 //SqlDataAdapter da = new SqlDataAdapter("select * from Student", connStr);
31 SqlDataAdapter da = new SqlDataAdapter("usp_getAllStuInfo", connStr);
32 DataTable dt = new DataTable();
33 da.Fill(dt);
34 this.dgvList.DataSource = dt;
35 }
36 #endregion
37
38 #region +void btnHasParamas_Click(object sender, EventArgs e)
39 /// <summary>
40 ///
41 /// </summary>
42 /// <param name="sender"></param>
43 /// <param name="e"></param>
44 private void btnHasParamas_Click(object sender, EventArgs e)
45 {
46 SqlDataAdapter da = new SqlDataAdapter("usp_getStuInfoBySexAndCname", connStr);
47 //1. , , sql
48 da.SelectCommand.CommandType = CommandType.StoredProcedure;
49 //2. , :
50 SqlParameter[] ps = {
51 new SqlParameter("@cname",this.cboClass.Text),//Text
52 new SqlParameter("@Sex",rdoMale.Checked?" ":" ")
53 };
54 //3.
55 da.SelectCommand.Parameters.AddRange(ps);
56 DataTable dt = new DataTable();
57 da.Fill(dt);
58 this.dgvList.DataSource = dt;
59 }
60 #endregion
61
62 #region Dgv +void Form1_Load(object sender, EventArgs e)
63 /// <summary>
64 /// Dgv
65 /// </summary>
66 /// <param name="sender"></param>
67 /// <param name="e"></param>
68 private void Form1_Load(object sender, EventArgs e)
69 {
70 #region
71 SqlDataAdapter da = new SqlDataAdapter("select classid ,classname from classes where classid<@num", connStr);
72 SqlParameter p = new SqlParameter("@num", 15);
73 SqlParameter p2 = new SqlParameter("@num2", 150);
74 da.SelectCommand.Parameters.Add(p2);
75 da.SelectCommand.Parameters.Add(p);
76 DataTable dt = new DataTable();
77 da.Fill(dt);
78 this.cboClass.DisplayMember = "classname";
79 this.cboClass.ValueMember = "classid";
80 this.cboClass.DataSource = dt;
81 #endregion
82
83 LoadDgvData();
84 }
85 #endregion
86
87 int pageIndex = 1; //
88 //int pageCount = 5;
89
90 #region +void btnOutput_Click(object sender, EventArgs e)
91 /// <summary>
92 ///
93 /// </summary>
94 /// <param name="sender"></param>
95 /// <param name="e"></param>
96 private void btnOutput_Click(object sender, EventArgs e)
97 {
98 SqlDataAdapter da = new SqlDataAdapter("usp_GetCountByCnameAndSex", connStr);
99 //1. , , sql
100 da.SelectCommand.CommandType = CommandType.StoredProcedure;
101 //2. , :
102 SqlParameter[] ps = {
103 new SqlParameter("@cname",this.cboClass.Text),//Text
104 new SqlParameter("@Sex",rdoMale.Checked?" ":" "),
105 // ,
106 // , Value
107 new SqlParameter("@totalCount",100),
108 new SqlParameter("@cnt",SqlDbType.Int),
109 new SqlParameter("@result",SqlDbType.Int)
110 };
111 //3. , , ,
112 ps[0].Direction = ParameterDirection.Input;// input,
113 //ps[2].Direction = ParameterDirection.Output;//
114 // ,
115 ps[3].Direction = ParameterDirection.Output;
116 ps[4].Direction = ParameterDirection.ReturnValue;
117 //3.
118 da.SelectCommand.Parameters.AddRange(ps);
119 DataTable dt = new DataTable();
120 da.Fill(dt);
121 this.dgvList.DataSource = dt;
122 this.lblMsg.Text = " :" + ps[2].Value + ", :" + ps[3].Value + ", :" + ps[4].Value;
123 }
124 #endregion
125
126 #region + void btnNext_Click(object sender, EventArgs e)
127 /// <summary>
128 ///
129 /// </summary>
130 /// <param name="sender"></param>
131 /// <param name="e"></param>
132 private void btnNext_Click(object sender, EventArgs e)
133 {
134 if (pageIndex.ToString() == System.Configuration.ConfigurationManager.AppSettings["totalPageCount"])
135 {
136 MessageBox.Show(" ");
137 return;
138 }
139 pageIndex++;
140 LoadDgvData();
141 }
142 #endregion
143
144 #region +void LoadDgvData()
145 /// <summary>
146 ///
147 /// </summary>
148 private void LoadDgvData()
149 {
150 string count = System.Configuration.ConfigurationManager.AppSettings["pageCount"];
151 SqlParameter[] ps ={
152 new SqlParameter("@pageIndex",pageIndex),
153 new SqlParameter("@pageCount",count),
154 new SqlParameter("@totalPageCount",SqlDbType.Int)
155 };
156 ps[2].Direction = ParameterDirection.Output;// --
157 this.dgvList.DataSource = SqlHelper.ExecuteTable("usp_getPageData", CommandType.StoredProcedure, ps);
158 System.Configuration.ConfigurationManager.AppSettings["totalPageCount"] = ps[2].Value.ToString();
159 }
160 #endregion
161
162 #region +void btnPre_Click(object sender, EventArgs e)
163 /// <summary>
164 ///
165 /// </summary>
166 /// <param name="sender"></param>
167 /// <param name="e"></param>
168 private void btnPre_Click(object sender, EventArgs e)
169 {
170 if (pageIndex == 1)
171 {
172 MessageBox.Show(" ");
173 return;
174 }
175 pageIndex--;
176 LoadDgvData();
177 }
178 #endregion
179 }
180 }
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Java 호출 Oracle 스토리지 프로세스 상세 정보Java 호출 Oracle 스토리지 프로세스 상세 정보 단계: 1. Oracle 스토리지 프로세스 작성 2. 데이터베이스 작성 연결 도구 클래스 얻기 3. 간단한 응용 프로그램 호출 저장 프로세스 작성 구현: 1. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.