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
}
继续追寻。。。。。。
查看全文
相关阅读:
ReenTrantLock可重入锁(和synchronized的区别)总结
什么是死锁?如何解决死锁?【转载】
android studio 完整安装教程,已完全实践过
foxmail创建163公司企业邮箱的时候会出现ERR Unable to log on
Android 开发 res里面的drawable(ldpi、mdpi、hdpi、xhdpi、xxhdpi)
android studio 突然出现Gradle project sync failed 错误
android 开发edittext获取焦点时hint消失
Z480联想笔记本突然没有了声音
android聊天,存储聊天记录sqlite
adb shell出现error错误
原文地址:https://www.cnblogs.com/lfzwenzhu/p/1519178.html
最新文章
Python2.6-原理之类和oop(上)
Python2.5-原理之模块
Python2.4-原理之函数
谷歌浏览器的各个版本对应的webdriver(chromedrive)-超级详细
python接口自动化(四)--接口测试工具介绍(详解)
python接口自动化(三)--如何设计接口测试用例(详解)
python接口自动化(二)--什么是接口测试、为什么要做接口测试(详解)
python接口自动化(一)--什么是接口、接口优势、类型(详解)
Dubbo简介
Pycharm使用教程(四)-安装python依赖包(非常详细,非常实用)
热门文章
Pycharm使用教程(三)(非常详细,非常实用)
安装需要的第三方库时,命令行输入pip提示不是内部或外部命令
SpringBoot中使用Redis
每月IT摘录201808--201809
java并发:volatile关键字
HashCode的理解
Redis事务的简单理解
Redis启动与使用
Redis发布订阅
Redis常用数据类型及命令
Copyright © 2011-2022 走看看