zoukankan
html css js c++ java
如何在c#中创建存储过程
Code
1
创建存储过程:
2
string
strSql
=
""
;
3
SqlConnection sqlCon
=
new
SqlConnection(Master.HeadStartConnString);
4
SqlCommand sqlCommStoreProcedue
=
new
SqlCommand();
5
sqlCommStoreProcedue.Connection
=
sqlCon;
6
sqlCommStoreProcedue.CommandType
=
CommandType.Text;
7
strSql
=
"
Create PROCEDURE #ImgeUpdate \n @RptImage Image, \n @RptDescription varchar(1000) \n as update Reports set RptImage = @RptImage, RptDescription = @RptDescription where RptID =
"
+
rptID;
8
sqlCommStoreProcedue.CommandText
=
strSql;
9
sqlCon.Open();
10
sqlCommStoreProcedue.ExecuteNonQuery();
11
执行存储过程:
12
SqlCommand sqlCom
=
new
SqlCommand();
13
sqlCom.Connection
=
sqlCon;
14
sqlCom.CommandType
=
CommandType.StoredProcedure;
15
sqlCom.CommandText
=
"
#ImgeUpdate
"
;
16
if
(filUL.HasFile)
17
{
18
int
intImgSize
=
filUL.PostedFile.ContentLength;
19
Stream ImgStream
=
filUL.PostedFile.InputStream;
20
byte
[] ImgContent
=
new
byte
[intImgSize];
21
int
intStatus
=
ImgStream.Read(ImgContent,
0
, intImgSize);
22
23
SqlParameter prmImg
=
new
SqlParameter(
"
@RptImage
"
, SqlDbType.Image);
24
prmImg.Value
=
ImgContent;
25
sqlCom.Parameters.Add(prmImg);
26
sqlCom.Parameters[
"
@RptImage
"
].Direction
=
ParameterDirection.Input;
27
}
28
SqlParameter prmDes
=
new
SqlParameter(
"
@RptDescription
"
, SqlDbType.VarChar,
1000
);
29
prmDes.Value
=
txtDesp.Text.ToString().Trim();
30
sqlCom.Parameters.Add(prmDes);
31
sqlCom.Parameters[
"
@RptDescription
"
].Direction
=
ParameterDirection.Input;
32
try
33
{
34
sqlCom.ExecuteNonQuery();
35
ClientScript.RegisterStartupScript(
this
.GetType(),
"
closeWin_Save
"
,
"
<script>alert('Save This Record Succeed!');window.close();</script>
"
);
36
}
37
catch
(SqlException sqlE)
38
{
39
ClientScript.RegisterStartupScript(
this
.GetType(),
"
Error_Msg
"
,
"
<script>alert('Save This Record Failing:
"
+
sqlE.Message
+
"
');</script>
"
);
40
}
41
finally
42
{
43
sqlCommStoreProcedue.Dispose();
44
sqlCom.Dispose();
45
sqlCon.Close();
46
}
继续追寻。。。。。。
查看全文
相关阅读:
python类方法和静态方法
42个创意户外广告设计
50免费为移动设计和开发的PSD文件极力推荐
40个高品质的免费商业PSD文件
10 个有用免费 CSS3 强大工具
10个方便的在线CSS代码生成器,网页设计师必备!
对makefile中,变量定义中 通配符的理解
GNU make manual 翻译(八十七)
GNU make manual 翻译(八十九)
GNU make manual 翻译(八十五)
原文地址:https://www.cnblogs.com/lfzwenzhu/p/1519178.html
最新文章
修改 Window Title 为当前目录
如何用 Win32 APIs 枚举应用程序窗口和进程
界面设计代码收集
net托管环境下struct实例字段的内存布局(Layout)和大小(Size) zt 武胜
串口通信 武胜
ping 服务端 武胜
生活处处有学问 武胜
enums in C# 转 武胜
User Control Closing Event 武胜
Ichimoku Kinko Hyo 武胜
热门文章
API与C#的数据类型对应关系表 zt 武胜
eclipse.ini内存设置
五种开源协议(GPL,LGPL,BSD,MIT,Apache)介绍
MIT、GPL、LPGL、BSD 的区别
UNIX环境高级编程中的apue.h错误
eclipse中文本编辑器的换行
Eclipse设置软tab(用4个空格字符代替)及默认utf8文件编码(unix)
oracle 存储过程
Python的字典操作
div 显示与隐藏
Copyright © 2011-2022 走看看