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
}
继续追寻。。。。。。
查看全文
相关阅读:
人工大脑项目 —— Nengo
四种聚类方法之比较
对淘宝一些规则的一些研究分享
【转】千万不要在夏季开发苹果应用,否则后果很严重
Windows2003上使用IIS7 Express使用FastCgi运行php
傅立叶变换最直白最容易理解最直接最真实最有深度的解释
音视频技术应用(18) 控制播放进度——av_seek_frame()
MySQL 中如何定位 DDL 被阻塞的问题
windows 编译版本异常处理
R语言的前世今生
原文地址:https://www.cnblogs.com/lfzwenzhu/p/1519178.html
最新文章
Windows Phone 项目实战之账户助手
程序员,对自己好一点
Windows Phone 社交分享SDK发布(新浪微博、腾讯微博、人人)
Windows Phone 7知识锦分享
Windows Phone 知识锦(12月版)
Windows Phone实用开发技巧(33):不重启程序切换当前语言
Windows Phone 实用开发技巧130合集(电子书+源代码)
Windows Phone 应用之博客园
Windows Phone 项目实战之我的微盘
Windows Phone 实用开发技巧(30):Pivot切换时同时渐变背景图片
热门文章
WinJS实用开发技巧(1):XML转JSON
Windows 8,VS 2012,SQL Server 2012,Office 2013使用体验
人生感悟与心得
简单回顾最近的几年
WPF企业内训全程实录(下)
WPF企业内训全程实录(中)
WPF企业内训全程实录(上)
MAC OSX 中,删除右键菜单中的多余重复项。
MAC PRO RETINA 下使用VMWARE以BOOTCAMP启动WIN8的性能下降一个档次
MAC OSX中游戏花屏或在VMWARE下开启3D发生花屏及贴图错误的解决
Copyright © 2011-2022 走看看